im trying to generate multiples arrays with one function, i have a For loop so i can save the results of my forEach in differents arrays, but after i=2 my function do not work. Any 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];
});
}