Q. What will be the output of the following code snippet?
Code:
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);
β
Correct Answer: (A)
[111, 44, 1, 22]