title: Why does adding two array lengths sum their index values instead of summing value of their actual length?
body: <p>I can see that the function is adding output[19] to output[18] to generate a sum of 4181, however why is the sum not 37?</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 fibonacciGenerator(n) {
  
    var output = [];
  
    for (var i = 0; i &lt; n; i++) {
      if (i &lt; 2) {
        output.push(i)
      } else {
        output.push(output[output.length - 1] + output[output.length - 2])
      }
    }
    console.log(output);
  }
  
  fibonacciGenerator(20);</code></pre>
  </div>
  </div>
  </p>