Q:

Comparing javascript array values

window.onload=function(){
        contents = new Array();
        painted = new Array();
        keys = 0;
        for(var i = 0; i < 4; i++){
            contents[i] = '';
            painted[i] = false;
        }
        contents[0] = 1;

    }

    function clicked(canvasNumber){
        if(contents[canvasNumber-1] == 1;){
            alert("you won!");
        }
    }

I am trying to get a pop up saying, "you won!" when canvas 1 is clicked, but the contents of my contents array are not matching up to trigger that alert. What am I doing wrong?

A:

if(contents[canvasNumber-1] == 1;){

should be
if(contents[canvasNumber-1] == 1){

with no semicolon in the if statement
Also your indexes are most likely not aligned.  

