JS function for validation of the brackets in a string
问题 guys! I want to ask you how can a make a function, that checks if the brackets in a string are put correctly. For example "(a + b).4,2 - )c + 5)" and I have to check the brackets. I tried something, but it doesn't seem to work(sorry, I'm a newbie in javascript): function checkBrackets(str){ var newOrder = []; var bracket1 = "("; var bracket2 = ")"; for(var bracket1 in str){ newOrder.push("1"); } for(bracket2 in str){ newOrder.pop(); } if(newOrder.length == 0){ console.log("Right!" + newOrder)