+ 2
guys how can i make 2D arrays in javascript ?!??! can you explane it to me with an example please!!
2D Arrays
2 odpowiedzi
+ 15
let's make a 10x10 multiplication board
var board = [] // main array
for(var i=1; i<=10; i++){
var row=[] // a single row
for(var j=1; j<=10; j++){
row.push(i*j) // push value
}
board.push(row) // push single row array
}
and for printing it
for(var i=0; i<10; i++){
document.write("<br>")
for(var j=0; j<10; j++){
document.write("["+board[i][j]+"]");
}
document.write("<br>")
}
+ 1
thanks that helped