Skip to content

Instantly share code, notes, and snippets.

@darksh3ll
Last active November 27, 2018 21:25
Show Gist options
  • Select an option

  • Save darksh3ll/358f8bab8e10c7c3f808e30a69e2f0a9 to your computer and use it in GitHub Desktop.

Select an option

Save darksh3ll/358f8bab8e10c7c3f808e30a69e2f0a9 to your computer and use it in GitHub Desktop.
validation parenthese fermante ouvrante
function validParentheses(parens){
const open= "(";
const closed= ")";
let totalOpen = 0;
let totalClose = 0;
for (let i = 0; i < parens.length; i++) {
if (parens[i] === open) {
totalOpen +=1
}else if (parens[i] === closed) {
totalClose +=1
}
}
return totalClose === totalOpen
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment