I saw one interview question .(i.e)
I have one array inside a function
function validate(){
var array=["(","{","[","]","}",")"];
}
Also i have one input field with submit button
<body>
<input type="text" name="equation" id="equation">
<input type="submit" name="check" value="check" onclick="validate();">
</body>
Now my doubt is when I enter input data as {()} it should display valid data in an alert.When I enter input data like {()}] it should display as invalid data.Which means for unbalanced input it should display invalid message.For that I need to compare array elements within an array.
How to do it?
validatedo ? What have you tried ?[(x+y)*(y-x)]but it should check only braces value doesn't matter.