title: Concat Arrays with For Loop
body: <p>After experimenting with the reduce method to flatten an array, I tried using a similar approach with a for-loop. 
  Can anyone explain why the for-loop doesn't flatten the array using concat? 
  P.S. I know that I can use a nested for-loop with Array.isArray to flatten as well. Just expected concat to work in a for-loop after seeing how reduce flattened the array.</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>var arrays = [
    [1, 2, 3],
    [4, 5],
    [6]
  ];
  
  console.log(arrays.reduce(function(arr, elem) {
    return arr.concat(elem);
  }, []));
  
  function flatten(arr) {
    var flat = [];
    for (var i = 0; i &lt; arr.length; i++) {
      flat.concat(arr[i]);
    }
    return flat;
  }
  console.log(flatten(arrays));</code></pre>
  </div>
  </div>
  </p>