Определите, сбалансирована ли сгенерированная строка скобок; то есть, состоит ли он целиком из пар открывающих / закрывающих скобок (в этом порядке), ни одно из которых не выполняется.
Примеры:(пусто) true
[] true
][ false
[][] true
][][ false
[]][[] false
[[[[]]]] true
isBalanced - это функция.
testString: 'assert(typeof isBalanced === "function", "isBalanced is a function.");'
- text: 'isBalanced("[]") должен возвращать true.'
testString: 'assert(isBalanced(testCases[0]), "isBalanced("[]") should return true.");'
- text: 'isBalanced("]][[[][][][]][") должен возвращать значение false.'
testString: 'assert(!isBalanced(testCases[1]), "isBalanced("]][[[][][][]][") should return false.");'
- text: 'isBalanced("[][[[[][][[[]]]]]]") должен возвращать true.'
testString: 'assert(isBalanced(testCases[2]), "isBalanced("[][[[[][][[[]]]]]]") should return true.");'
- text: 'isBalanced("][") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[3]), "isBalanced("][") should return true.");'
- text: 'isBalanced("[[[]]]][[]") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[4]), "isBalanced("[[[]]]][[]") should return true.");'
- text: 'isBalanced("][[]") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[5]), "isBalanced("][[]") should return true.");'
- text: 'isBalanced("][[][]][[[]]") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[6]), "isBalanced("][[][]][[[]]") should return true.");'
- text: 'isBalanced("[[][]]][") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[7]), "isBalanced("[[][]]][") should return true.");'
- text: 'isBalanced("[[[]]][[]]]][][[") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[8]), "isBalanced("[[[]]][[]]]][][[") should return true.");'
- text: 'isBalanced("[]][[]]][[[[][]]") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[9]), "isBalanced("[]][[]]][[[[][]]") should return true.");'
- text: 'isBalanced("][]][[][") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[10]), "isBalanced("][]][[][") should return true.");'
- text: 'isBalanced("[[]][[][]]") должен возвращать true.'
testString: 'assert(isBalanced(testCases[11]), "isBalanced("[[]][[][]]") should return true.");'
- text: 'isBalanced("[[]]") должен возвращать true.'
testString: 'assert(isBalanced(testCases[12]), "isBalanced("[[]]") should return true.");'
- text: 'isBalanced("]][]][[]][[[") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[13]), "isBalanced("]][]][[]][[[") should return true.");'
- text: 'isBalanced("][]][][[") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[14]), "isBalanced("][]][][[") should return true.");'
- text: 'isBalanced("][][") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[15]), "isBalanced("][][") should return true.");'
- text: 'isBalanced("[[]]][][][[]][") должен возвращать true.'
testString: 'assert(!isBalanced(testCases[16]), "isBalanced("[[]]][][][[]][") should return true.");'
- text: isBalanced("") должен возвращать true.
testString: 'assert(isBalanced(testCases[17]), "isBalanced("") should return true.");'
```