function rotateImage(arr) {
// rotates a 2D array 90 degrees to the right (clockwise)
var newarr = [];
for(let x = 0; x < arr[0].length; x++){
newarr[x] = [];
for(let y = arr.length - 1; y >= 0; y--){
newarr[x].push( arr[y][x] );
}
}
return newarr;
}
console.log(rotateImage([[1,2,3],
[4,5,6],
[7,8,9]]));