A

Admin • 833K Points
Coach

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]
  • Correct Answer - Option(A)
  • Views: 25
  • Filed under category JavaScript
  • Hashtags:

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.

Be the first to start discuss.