Skip to content

Instantly share code, notes, and snippets.

@Belouccio
Created February 2, 2017 19:48
Show Gist options
  • Select an option

  • Save Belouccio/652e9aa7fd44a6ade8bafa9f334be085 to your computer and use it in GitHub Desktop.

Select an option

Save Belouccio/652e9aa7fd44a6ade8bafa9f334be085 to your computer and use it in GitHub Desktop.
function myFunc(str){
var shablon="a(){}[]";
var stek=[];
for (var i=0; i<str.length; i++){
var x=str[i];
var y=shablon.indexOf(x);
if (y>0){
if(y%2==0){
if(!stek.length){
return console.log("не правильно");
}
var z=stek.pop();
if(z!=shablon[y-1]){
return console.log("не правильно");
}
} else {
stek.push(x);
}
}
}
return (stek.length)? console.log("не правильно") : console.log("правильно");
}
myFunc("{{{}}}()[[][]]");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment