character counter in 2D array
<p>I tried to create a 2D array and place four <code>X</code> in the same column. I created a loop for detecting and counting the number of <code>X</code>s but it doesn't work.</p>

<pre><code> var creatematrix = function (nbRang, nbColumn) {
    var result = Array(nbRang);
    for (var i=0; i&lt;nbRang; i++) {
        result[i] = Array(nbColumn);
    }
    return result;
};

var m = creatematrix(2, 6);

m[1][2] = "X";
m[1][3] = "X";
m[1][4] = "X";
m[1][5] = "X";

   var sumX = 0

   for(var k = 0; k &lt; 6 ; k++){



                  if(m[1][k]== "X"){
                    sumX += 1;   

             }else if(sumX == 4){

                   alert("player won");  
                }   

   }
</code></pre>
