title: uncaught typeerror cannot read property '0' of undefined within a for loop
body: <p>I am working on a project to make a mastermind. Everything is going well except 
  This is giving me following error --> uncaught typeerror cannot read property '0' of undefined.</p>
  
  <pre><code>    function vergelijking(computer, speler)
      {
          var arrayVergelijken = [];
  
          for(var i = 0; i &lt; arrayLengte; i++)
          {
              if(computer[i] === speler[i])
              {
                  arrayVergelijken.push("1");
              }
              else
              {
                  arrayVergelijken.push("0");
              }
          }
  
          return arrayVergelijken;
      }
  </code></pre>
  
  <p>EDIT: typos <br>
  I have made some changes to the code. It is working better then before. But there is still a strange thing. The code is giving me a '0' every time. Like when I try all the colours ( geel, groen, rood, blauw, oranje) the respons i'm getting is a zero. Normally when A colour is matching with the random colour of the computer, the code should give me a one '1'.</p>
  
  <p>EDIT: I have made some changes and now the program is doing great. It does everything that I wanted from it. Happy :) --> <a href="http://pastebin.com/VJWj3uc3" rel="nofollow">http://pastebin.com/VJWj3uc3</a></p>