Javascript stack
\nvar minAddToMakeValid = function(S) {\n  const stack = []\n  for(let s of S){\n    if(s === \')\' && stack[stack.length-1] === \'(\')\n      stack.pop()\n    
```\nvar minAddToMakeValid = function(S) {\n  const stack = []\n  for(let s of S){\n    if(s === \')\' && stack[stack.length-1] === \'(\')\n      stack.pop()\n    else\n      stack.push(s)\n  }\n  return stack.length\n};\n```
['JavaScript']