title: JavaScript array reduction
body: <pre><code>function init(){
  var panel = document.getElementById("panel");
  var i;
  
  var week = ["monday","tuesday","wednesday","thursday","friday"];
  var weekend = ["saturday","sunday"];
  
  panel.innerHTML+="weekdays: "+ week;
  panel.innerHTML+="&lt;hr&gt;weekend days: "+ weekend;
  
  for(i=0; i&lt;weekend.length; i++)
  {
      week[week.length]=weekend[i];
  }
  
  panel.innerHTML+="&lt;hr&gt;increased with weekend days: "+week;
  
  week-=2;
  
  panel.innerHTML+="&lt;hr&gt;reduced back to weekdays: "+week;
  }
  window.onload=init;
  </code></pre>
  
  <p>this is the main js code it is loaded from another html file. everything is working fine until the end. the last output should be "reduced back to weekdays: monday,tuesday,wednesday,thursday,friday" but what im getting is this "reduced back to weekdays: NaN", what does this error mean and how can i fix it?</p>