File tree 1 file changed +3
-17
lines changed
1 file changed +3
-17
lines changed Original file line number Diff line number Diff line change @@ -10,34 +10,20 @@ export function parenthesesChecker(symbols: string) {
10
10
let top : string ;
11
11
12
12
while ( index < symbols . length && balanced ) {
13
- symbol = symbols . charAt ( index ) ;
13
+ symbol = symbols [ index ] ;
14
14
if ( opens . indexOf ( symbol ) >= 0 ) {
15
15
stack . push ( symbol ) ;
16
- // console.log(`open symbol - stacking ${symbol}`);
17
16
} else {
18
- // console.log(`close symbol ${symbol}`);
19
17
if ( stack . isEmpty ( ) ) {
20
18
balanced = false ;
21
- // console.log('Stack is empty, no more symbols to pop and compare');
22
19
} else {
23
20
top = stack . pop ( ) ;
24
- // if (!matches(top, symbol)){
25
21
if ( ! ( opens . indexOf ( top ) === closers . indexOf ( symbol ) ) ) {
26
22
balanced = false ;
27
- /* console.log(
28
- `poping symbol ${top} - is not a match compared to ${symbol}`
29
- ); */
30
- } /* else {
31
- console.log(
32
- `poping symbol ${top} - is is a match compared to ${symbol}`
33
- );
34
- } */
23
+ }
35
24
}
36
25
}
37
26
index ++ ;
38
27
}
39
- if ( balanced && stack . isEmpty ( ) ) {
40
- return true ;
41
- }
42
- return false ;
28
+ return balanced && stack . isEmpty ( ) ;
43
29
}
You can’t perform that action at this time.
0 commit comments