Q:

Write a JavaScript program to move the specified amount of elements to the end of the array

0

Write a JavaScript program to move the specified amount of elements to the end of the array. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)];
console.log(offset([1, 2, 3, 4, 5], 2));
console.log(offset([1, 2, 3, 4, 5], -2));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now