Skip to content

Instantly share code, notes, and snippets.

@aamirafridi
Last active August 2, 2020 17:08
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 aamirafridi/d8fc59e58286120803853d4767edcdf0 to your computer and use it in GitHub Desktop.
Save aamirafridi/d8fc59e58286120803853d4767edcdf0 to your computer and use it in GitHub Desktop.
function rotLeft(a, d) {
if (a.length === d) return a;
// arrays are Non-Primitive data type so create a shallow copy
var copy = [...a];
while(d) {
copy.push(copy.shift());
d--;
}
return copy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment