Answers for "how to rotate an array in javascript"

0

how to rotate an array in javascript

function arrayRotate(arr, reverse) {
  if (reverse) arr.unshift(arr.pop());
  else arr.push(arr.shift());
  return arr;
}
Posted by: Guest on July-04-2021

Code answers related to "how to rotate an array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language