var cols = 9;
var rows = 9;
var matrix_empty = [];
for (var x = 0; x < cols; x++) {
matrix_empty[x] = [];
for (var y = 0; y < rows; y++) {
matrix_empty[x][y] = -1;
}
}
console.log(matrix_empty); //here give me wrong result not -1 in whole position
matrix_test = getRandomMatrix(matrix_empty);
function getRandomMatrix(matrix) {
matrix[0][1] = 39;
matrix[1][1] = 9;
matrix[2][2] = 9;
return matrix;
}
Question:
Why console log give me wrong result? They give me:
matrix[0][1] =39;
matrix[1][1] = 9;
matrix[2][2] = 9;
but I expect -1 in whole matrix!
What should i do, that this give me -1 in the whole matrix in console.log (set in this position)
I tested this in Firefox and Chrome.