1var rotateTheBox = function (box) {2for (let r = 0; r < box.length; r++) {3let idx = null;4for (let c = 0; c < box[r].length; c++) {5const curr = box[r][c];6if (curr === "*") {7idx = null;8continue;9}10if (curr === "#" && idx === null) {11idx = c;12continue;13}14if (curr === "." && box[r][idx] === "#" && idx <= c) {15box[r][idx] = ".";16box[r][c] = "#";17idx++;18}19}20}21return transpose(box);22};2324function transpose(arr) {25const B = [];26for (let c = 0; c < arr[0].length; c++) {27if (!B[c]) B[c] = [];28for (let r = 0; r < arr.length; r++) {29B[c][r] = arr[r][c];30}31B[c].reverse();32}33return B;34}