title: unidentified when alerting array
body: <p>When I run this it alerts unidentified whenever <code>worldgeny == 400</code> and i do not know why.
  If i alert <code>worldgeny</code> in the same place it alerts <code>NaN</code>. I may have not explained this very well. if you are confused just ask.
  My code is messy I know this is just a test for me personally
  Thanks in advance</p>
  
  <pre><code>var addy;
  var worldgeny = parseInt(200);
  var mul5 = parseInt(0);
  var endhole;
  var holegen;
  var sizeh = 30;
  var sizew = 30;
  var savey = [];
  
  function cworld() {
      mul5++;
      posX++;
      canvasContext.drawImage(imageGround, posX, worldgeny, 1, 400);
          if(mul5 % 30 == 0){
              if(worldgeny==400){
                  endhole = mul5/30;
                  endhole = endhole - 1;
                  worldgeny=savey[endhole];
                  alert(savey[endhole])
              }
              addy = parseInt(Math.floor((Math.random()*30)-17));
              holegen = parseInt(Math.floor((Math.random()*5)));
              worldgeny += addy;
              if(holegen==1){
                  worldgeny = 400;
              }
              savey.push(worldgeny);
          }
      }
  setInterval(cworld, 1);
  </code></pre>