Last active
August 2, 2020 17:08
-
-
Save aamirafridi/d8fc59e58286120803853d4767edcdf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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