title: Finding the sum of a nested array
body: <p>I tried finding the sum of all numbers of a nested array, but I don't get it to work correctly. This is what I tried:</p>
  <pre><code>function arraySum(i) {
    sum = 0;
    for (a = 0; a &lt; i.length; a++) {
      if (typeof i[a] == 'number') {
        sum += i[a];
      } else if (i[a] instanceof Array) {
        sum += arraySum(i[a]);
      }
    }
    return sum;
  }
  </code></pre>
  <p>When you try it out with the array <code>[[1,2,3],4,5]</code>, it gets <code>6</code> as the answer, instead of <code>15</code>.
  Does somebody know where there is a mistake in it?</p>