title: recursive approach to nested arrays without using .concat or .reduce in JavaScript
body: <p>I'm working on a simple recursive approach to flattening arrays, and I can't figure out where I'm going wrong. I've seen other threads on this (<a href="https://stackoverflow.com/questions/27266550/how-to-flatten-nested-array-in-javascript">How to flatten nested array in javascript?</a>) but I'm trying to do it without using .concat or .reduce. </p>
  
  <p>This one keeps looping, but I'm not sure why- looks like it should hit the most nested array and return whatever characters within it.</p>
  
  <p>Thanks!</p>
  
  <pre><code>var ret= [];
  var nested = [['a','b'],[],'c',['d','e']];
  function flatten(arr) {
    for (i = 0; i &lt; arr.length; i++) {
      if (Array.isArray(arr[i])) {
        flatten(arr[i]);
      } else {
          ret.push(arr[i]);
      }
    }
  }
  flatten(nested);
  </code></pre>