I'm trying to avoid hardcoding 2d matrix grids by using JavaScript new Array()
.
In theory, it works, but in practice, I receive a bug. While a hardcoded grid swaps nearest gems correctly, the new Array
method swaps them almost randomly with the same code
me.tileGrid = new Array(6).fill(new Array(6).fill(null));
/* The upper code is potentially scalable, but it doesn't work same */
me.tileGrid = [
[null, null, null, null, null, null],
[null, null, null, null, null, null],
[null, null, null, null, null, null],
[null, null, null, null, null, null],
[null, null, null, null, null, null],
[null, null, null, null, null, null]
];