daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function braces(values) {
  2.     let bracesCount = 0;
  3.     for (let index; index < values.length; index++) {
  4.         const str = value[index]
  5.         let countRound, countSquare, countCurly = 0;
  6.         for (let i in str) {
  7.             switch(str[i]) {
  8.                 case '(':
  9.                     countRound++;
  10.                     break;
  11.                 case ')':
  12.                     countRound--;
  13.                     break;
  14.                 case '[':
  15.                     countSquare++;
  16.                     break;
  17.                 case ']':
  18.                     countSquare--;
  19.                     break;
  20.                 case '{':
  21.                     countCurly++;
  22.                     break;
  23.                 case '}':
  24.                     countCurly--;
  25.             }
  26.         }
  27.        
  28.         if (countRount === 0 && countSquare === 0 && countCurly === 0) {
  29.             value[index] = "YES";
  30.         } else {
  31.             value[index] = "NO";
  32.         }
  33.     }
  34.  
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top