title: Javascript Scope and Recursion
body: <p>When calling this function I am expecting <code>myStrings</code> to be <code>['A','B','C','D','E','F','G']</code> when in fact I'm seeing <code>['A', 'B', 'G']</code>. When the recursive call is made <code>a[i]</code> equals <code>[['C','D'],'E','F']</code> however the function receives the entire <code>myArray</code>. Any ideas?</p>
  
  <pre><code>var myArray = ['A','B',[['C','D'],'E','F'],'G'];
  
  var myStrings = [];
  
  function extractStrings(a) {
  
      for(var i=0; i&lt;a.length; i++) {
  
          if(typeof a[i] === 'string') {
              myStrings.push(a[i]);
          } else if (typeof a[i] === 'object') {
              extractStrings[a[i]];
          }
      }
  }
  
  extractStrings(myArray);
  console.log(myStrings);
  </code></pre>