Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rotateArray(input) {
- let numberRotation = Number(input.pop());
- if (numberRotation > 0 && input.length > 0) {
- for (let i = 1; i <= numberRotation; i++) {
- let currentElement = input.pop();
- input.unshift(currentElement);
- }
- console.log(input.join(' '));
- } else {
- console.log('Empty');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment