function solve(arr, rotations){ if(rotations == 0) return arr; for(let i = 0; i < rotations; i++){ let element = arr.pop(); arr.unshift(element); } return arr; } // solve([44, 1, 22, 111], 5);