Sobes.tech
Junior — Senior

Validation of correct bracket nesting

livecode

Task condition

It is necessary to implement a function that determines whether the brackets are correctly placed in the given string.

function checkBrackets(str) {
}

// '({{}})'
console.log(checkBrackets('([](){{()}})')) // true
console.log(checkBrackets('()[{}]'))        // true
console.log(checkBrackets('({[})]'))        // false
console.log(checkBrackets('([[]))'))        // false
console.log(checkBrackets('{()}'))          // false

// Assumption: the input string consists solely of the characters ()[]{}