Skip to content

Instantly share code, notes, and snippets.

@BiosBoy
Created March 14, 2024 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BiosBoy/30af3ab5c46245167f66402f743a1463 to your computer and use it in GitHub Desktop.
Save BiosBoy/30af3ab5c46245167f66402f743a1463 to your computer and use it in GitHub Desktop.
const rotLeft = (a, d) => {
const rotArr = [...Array(d).keys()];
rotArr.forEach(() => a.push(...a.splice(0, 1)));
return a;
};
console.log(rotLeft([1, 2, 3, 4, 5], 4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment