Hello,
I get this one
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]
].
instead of
[0, 0],
[0, 0],
[0, 0]
]
I dont know how to fix in order to get this, even if the fcc says that i succeeded, because i paste let row in the for loop.
The challenge is this one : https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging/use-caution-when-reinitializing-variables-inside-a-loop/
my code is this (which pass the challenge ) :
function zeroArray(m, n) {
// Creates a 2-D array with m rows and n columns of zeroes
let newArray = [];
for (let i = 0; i < m; i++) {
// Adds the m-th row into newArray
let row = [];
for (let j = 0; j < n; j++) {
// Pushes n zeroes into the current row to create the columns
row.push(0);
}
// Pushes the current row, which now has n zeroes in it, to the array
newArray.push(row);
}
return newArray;
}
let matrix = zeroArray(3, 2);
console.log(matrix);
but in yhe output i dont get
[0, 0],
[0, 0],
[0, 0]
]
I didn’t get it but this one [0, 0, 0, 0, 0, 0]
Ok thank you