thank you in advance for taking the time to help me with this question.
I am trying to generate a simple board like so, using a for loop.
var board = [[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]];
However, my attempt below has not been successful.
function makeBoard(n){
var board=[];
for(var i=0; i<n; i++){
for(var j=0; j<n; j++){
board[i][j]=0;
}
}
return board;
}
Technically, I could just use the board variable I have shown above, and continue, but I am more concerned with the principle. Is it not possible to create a multidimensional array using for loop? Is there a simple way to accomplish this using array.push()?