1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27const match = { ')': '(', ']': '[', '}': '{', }; function validBraces(braces){ const stack = []; for (const ch of Array.from(braces)) { switch(ch) { case '(': case '[': case '{': stack.push(ch); break; case ')': case ']': case '}': if (stack.pop() !== match[ch]) { return false; } break; } } return stack.length === 0; }