function isBracketsBalanced(str) {
  const stack = [];
  const brackets = { '[': ']', '{': '}', '(': ')', '<': '>' };
  for (let i = 0; i < str.length; i++) {
    if (brackets[stack[stack.length - 1]] === str[i]) {
      stack.pop();
    } else {
      stack.push(str[i]);
    }
  }
  return !stack.length;
}
/**
 * Returns true if the specified string has the balanced brackets and false otherwise.
 * Balanced means that is, whether it consists entirely of pairs of opening/closing brackets
 * (in that order), none of which mis-nest.
 * Brackets include [],(),{},<>
 *
 * @param {string} str
 * @return {boolean}
 *
 * @example:
 *   '' => true
 *   '[]'  => true
 *   '{}'  => true
 *   '()   => true
 *   '[[]' => false
 *   ']['  => false
 *   '[[][][[]]]' => true
 *   '[[][]][' => false
 *   '{)' = false
 *   '{[(<{[]}>)]}' = true
 */
Returns true if the specified string has the balanced brackets and false otherwise.
Balanced means that is, whether it consists entirely of pairs of opening/closing brackets
(in that order), none of which mis-nest.

@param {string} str
@return {boolean}


Returns true if the specified string has the balanced brackets and false otherwise . Balanced means that is whether it consists entirely of pairs of opening / closing brackets ( in that order ) none of which mis - nest . @param { string } str @return { boolean }
function isBracketsBalanced(str) {
  const stack = [];
  const brackets = { '[': ']', '{': '}', '(': ')', '<': '>' };
  for (let i = 0; i < str.length; i++) {
    if (brackets[stack[stack.length - 1]] === str[i]) {
      stack.pop();
    } else {
      stack.push(str[i]);
    }
  }
  return !stack.length;
}
function isBracketsBalanced ( str ) { const stack = [ ] ; const brackets = { '[' : ']' , '{' : '}' , '(' : ')' , '<' : '>' } ; for ( let i = 0 ; i < str . length ; i ++ ) { if ( brackets [ stack [ stack . length - 1 ] ] === str [ i ] ) { stack . pop ( ) ; } else { stack . push ( str [ i ] ) ; } } return ! stack . length ; }
Returns true if the specified string has the balanced brackets and false otherwise.
Returns true if the specified string has the balanced brackets and false otherwise .