Array().fill acts weirdly
If I do matrix[0][0] = "a" in option 1 matrix, it replaces entire 1st column with "a". But that's not the case for option 2, it only only replaces at the specified position.
// Option 1
function initialize() {
let matrix = new Array(3).fill(["-", "-", "-"]);
return matrix;
};
// Option 2
function initialize() {
let matrix = new Array();
for (; matrix.length < 3;) {
let row = ["-", "-", "-"];
matrix.push(row);
};
return matrix;
};