title: Passing array as argument to a js function
body: <p>I wanted to create a basic function summing up values from an array. I'm aware of the array reduce method but i wanted initially to use a loop "for" instead as below...however it returns NaN...why ? </p>
  
  <pre><code>var numbers=[1,2];
  var total;
  function sum(array){
     total=0;
     for(var x=0;x&lt;=array.length;x++){    
      total += array[x];
     }
     return total;
  }
  </code></pre>