Home / Programming MCQs / JavaScript MCQs / Question

M

Mohini Yadav • 27.60K Points
Instructor II

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);
(A) [111, 44, 1, 22]
(B) [44, 1, 22, 111]
(C) [111, 44, 1, 22]
(D) [1, 22, 111, 44]

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.