/* I have tried this I get an equal number of "(" count but I don't how to check that it is preceded by a corresponding or not*/
function checkStr(str)
{
len = str.length;
let count =0;
let count1=0;
for(let i=0; i<=len;i++)
{
if(str[i]==')')
{
count++;
}
else if(str[i]=='(')
{
count1++;
}
}
if(count==count1)
{
return true;
}
else{
return false;
}
}
let result=checkStr("))a+b((");
console.log(result)
output
should be false but I'm getting True