TZinovieva

Array Rotation JS

Jan 26th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function arrayRotation(arr, rot) {
  2.     for (let i = 0; i < rot; i++) {
  3.         let currentElement = arr[0];
  4.         arr.shift();
  5.         arr.push(currentElement);
  6.     }
  7.     console.log(arr.join(` `));
  8. }
Advertisement
Add Comment
Please, Sign In to add comment