girar a matriz de 90 graus JavaScript no sentido horário
// transpone
const transpose = matrix => {
for (let row = 0; row < matrix.length; row++) {
for (let column = 0; column < row; column++) {
let temp = matrix[row][column]
matrix[row][column] = matrix[column][row]
matrix[column][row] = temp
}
}
return matrix;
}
// reverse
const reverse = matrix => matrix.map(row => row.reverse());
// rotate
const rotate = matrix => transpose(reverse(matrix));
code fighter