I can't seem to fix this problem. My code is as follows:
var matrix = [];
// initialise the grid:
window.onload = function(){
var cells ='';
for(var i = 0; i < 10; i++){
matrix[i] = [];
for (var j = 0; j < 10; j++){
matrix[i][j] = "white";
cells += "<span class = 'cell' id='cell"+ i + "" + j + "' onClick = 'toggleCell("+i+","+j+")' ></span>";
}
}
$('#grid-container').html(cells);
}
When I try to call elements of matrix in other methods, I get undifined.
SOLVED
- tried to access objects at invaldi positions later on.