Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
If the stack is empty then
stack.pop()
returnsundefined
the comparison to "(" in the else statement only checks if stack.pop failed due to not having any more entries.
Cant get why we can have true in else statement. It seems that we are only adding '(' to the stack.
Great solution but it will not work if you have normal text in the input string.
great solution, it has changed my mind, i never assumed that there is a possibility to solve this way.
I remembered doing an "easier" kata with this same problem that had square brackets as well as curly braces that used this same method so I tried replicating it off memory and I ended up with something a little more complicated. Seems I forgot to include the stack.pop() in the else if statement and went a roundabout way.
All this to say that I like this method much better than the regex ones.
phew, I thought everyone forgot about stacks