Valid parentheses
EasyStacks · JavaScript
The task
Write isValid(s) for a string containing only the characters ( ) [ ] { }.
Return true if every opening bracket is closed by the same kind of bracket, in the correct order. An empty string is valid.
Examples
- isValid("([]{})") returns true
- isValid("(]") returns false
Your code runs in your browser, in a separate worker, and is never sent to us. Edit the function, then press Run tests. Your work is saved here as you type.
JavaScriptCtrl or Cmd + Enter to run