title: return function within if statement not executing
body: <p>Hey so i'm writing a function that checks whether a series of braces is a valid sequence. I have the following code, which mostly does what I want it to do, except it it always returns false. If i enter a valid sequence of braces it ends up in the right if-statement, but never returns true. I don't understand why.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function match(s) {
    if (s === '(') {
      return ')'
    }
    else if (s === '[') {
      return ']'
    }
    else if (s === '{') {
      return '}'
    }
  }
  
  function open(b) {
    if ( (b === '(' ) || (b === '[' ) || (b === '{') ) {
      return true;
    }
    return false;
  }
  
  function checkValid(string, temp, n) {
    var current = string.charAt(n)
    var currentMatch = temp.charAt(0)
  
    if (!(current) &amp;&amp; (n === string.length) &amp;&amp; (temp === "")) {
      console.log('hey')
      return true
    }
  
    if (open(current)) {
      temp = match(current).concat(temp)
      checkValid(string, temp, n+1)
    }
    else {
      if (current === currentMatch) {
        temp = temp.substr(1)
        checkValid(string, temp, n+1)
      }
      return false;
    }
    return false;
  }
  
  function validBraces(braces) {
    var n = 0
    var temp = ''
    return checkValid(braces, temp, n)
  }
  
  validBraces('()') // should return true
  validBraces('[[)}}{') //should return false</code></pre>
  </div>
  </div>
  </p>