check for balanced parentheses in javascript
function Check()
{
let s = [];
let pObj = {'{':'}','(':')','[':']'}
let sTop = "";
for(let i=0;i<str.length;i++)
{
if(str[i] == '{' || str[i] == '(' || str[i] == '[')
{
s.push(str[i]);
}
else
{
sTop = s.pop();
if(str[i] !== pObj[sTop])
{
return 0;
}
}
}
return 1;
}
var str = userInput[0];
res = Check(str);
if(res == 0)
{
console.log("Unbalanced");
}
else
{
console.log("Balanced");
}
Also in JavaScript:
- check uncheck vanila js
- get execution time in javascript
- swap function javascript
- universal apollo kit
- turn text into links javascript
- UltraExploit.js
- Expected an assignment or function call and instead saw an expression
- define a while loop in node js
- render props
- javascript create checkbox with label
- javascript countdown 1 minute
- ngx-translate angular 11
- single if statement js true false
- set css variable from javascript
- javascript set input field value
- string comparison in javascript
- add class to html tag javascript
- js create object url base64 pdf binary
- less than or equal js
- npm react native turn by turn navigation
- nodejs btoa
- testing library react hooks
- python json.dumps pretty print
- shopify image pciker