Estoy tratando de generar matrices múltiples con una función, tengo un ciclo For para poder guardar los resultados de mi forEach en diferentes matrices, pero después de i=2 mi función no funciona. ¿Algunas ideas?
for (let i=0; i<4;i++){ if(i==0){ tempArray=arrayzero; console.log(tempArray) rotateGrid(tempArray); }else if(i==1){ arrayone=newDecriptorGrid; tempArray=arrayone console.log(arrayone); rotateGrid(tempArray); }else if(i==2){ arraytwo=newDecriptorGrid; tempArray=arraytwo; console.log(arraytwo); rotateGrid(tempArray); } } function rotateGrid(gridToTurn){ gridToTurn.forEach((element,index) => { newElement[index]=[]; newElement[index][x] = (gridSize + 1) - element[y]; newElement[index][y] = element[x]; newDecriptorGrid[index] = newElement[index]; }); }