Skip to content

Commit f06c85c

Browse files
authored
Merge pull request loiane#50 from christianbender/improved_balanced_symbols
improved the algorithm
2 parents 890180c + fa3d96b commit f06c85c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/js/others/balanced-symbols.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function parenthesesChecker(symbols) {
1111
let top;
1212

1313
while (index < symbols.length && balanced) {
14-
symbol = symbols.charAt(index);
14+
symbol = symbols[index];
1515
if (opens.indexOf(symbol) >= 0) {
1616
stack.push(symbol);
1717
} else if (stack.isEmpty()) {
@@ -24,8 +24,5 @@ export function parenthesesChecker(symbols) {
2424
}
2525
index++;
2626
}
27-
if (balanced && stack.isEmpty()) {
28-
return true;
29-
}
30-
return false;
27+
return balanced && stack.isEmpty();
3128
}

0 commit comments

Comments
 (0)