Use Caution When Reinitializing Variables Inside a Loop
Final Code
functionzeroArray(m,n){// Creates a 2-D array with m rows and n columns of zeroesletnewArray=[];letrow=[];for(leti=0;i<m;i++){// Adds the m-th row into newArrayletrow=[];for(letj=0;j<n;j++){// Pushes n zeroes into the current row to create the columnsrow.push(0);}// Pushes the current row, which now has n zeroes in it, to the arraynewArray.push(row);}returnnewArray;}letmatrix=zeroArray(3,2);console.log(matrix);