JavaScript Clean One Pass
javascript\nvar minAddToMakeValid = function(S) {\n    let open = 0, close = 0;\n    \n    for(let c of S) {\n        if(c === \'(\') open++;\n        else if(!
```javascript\nvar minAddToMakeValid = function(S) {\n    let open = 0, close = 0;\n    \n    for(let c of S) {\n        if(c === \'(\') open++;\n        else if(!open) close++;\n        else open--;\n    }\n    return open + close;\n};\n```
['JavaScript']