JSFiddle - React, Tailwind, and code Playground
HTML
<script>
var p
function f01(x,findchr){
if (findchr=='') {p=-1}
var f=true;
do{
p++
if (x[p]==findchr) {return true}
else {
switch(x[p]){
case '(': f=f01(x,')'); break;
case '<': f=f01(x,'>'); break;
case '[': f=f01(x,']'); break;
case '{': f=f01(x,'}'); break;
case (')'||'>'||']'||'}'): p=x.length; return false;
}
}
}while(p<x.length)
return f && (findchr=='')
}
function u(){
w.innerHTML='Результат проверки: '+f01(gg.value,'')
}
</script>
<input type="text" value="ab{cd)}[,,,,]" size="50px" id="gg">
<br>
<input type="button" id="btn" value="Проверить" onclick="u()">
<p id="w">
</p>
CSS
#gg{
width: 350px;
font-family: monospace;
font-size: 26px;
}