I am going to change the element of 2D array by its indices
When I was solving CodeWars problems. I tried to change the element which located 4th row 2nd column, the compiler changed all the elements located in the 2nd column
function score( dice ) {
// Fill me in!
const map = new Map();
let arr = [];
let init = [0, 0, 0, 0, 0, 0, 0];
for(let i=0; i<6; i++) {
arr.push(init);
}
arr[3][1] = 1000;
console.log(arr);
}
/**
CONSOLE
[
[
0, 1000, 0, 0,
0, 0, 0
],
[
0, 1000, 0, 0,
0, 0, 0
],
[
0, 1000, 0, 0,
0, 0, 0
],
[
0, 1000, 0, 0,
0, 0, 0
],
[
0, 1000, 0, 0,
0, 0, 0
],
[
0, 1000, 0, 0,
0, 0, 0
]
]
*/
Is the problem with my code or with the compiler?