Last active
November 27, 2018 21:25
-
-
Save darksh3ll/358f8bab8e10c7c3f808e30a69e2f0a9 to your computer and use it in GitHub Desktop.
validation parenthese fermante ouvrante
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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