0๐
โ
I think that issue is when you were creating the 3d array. You probably used fill which would make references to the same array and thus result would be what you have shown.
Here is a working example:
const size = 5
const fill = 0
const arr = new Array(size).fill(0).map(() => new Array(size).fill(0).map(() => new Array(size).fill(fill)))
arr[0][0][0] = 1
console.info(arr)
Source:stackexchange.com