added exo-4
This commit is contained in:
1 parent
b366ff6879
commit
ad0683528b
5 files changed
+185
No files matched your search
@@ -0,0 +1,15 @@
|
||||
export function isBalanced(str){
|
||||
let counter = 0;
|
||||
for(const letter of str){
|
||||
if(letter === "("){
|
||||
counter += 1;
|
||||
}
|
||||
if(letter === ")"){
|
||||
counter -= 1;
|
||||
}
|
||||
if(counter < 0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return counter === 0;
|
||||
}
|
||||
Reference in new issue
Block a user