Skip to content

Instantly share code, notes, and snippets.

@Obre
Last active March 24, 2017 12:19
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 Obre/863ae67520c5ee2532159c52f3a901c8 to your computer and use it in GitHub Desktop.
Save Obre/863ae67520c5ee2532159c52f3a901c8 to your computer and use it in GitHub Desktop.
function solution(A, K) {
if(A !== undefined && A.length > 0)
{
for(let i =0; i < K; i++){
A.unshift(A.pop());
//unshift add element/s to begin of array and returns length of new array
//pop removes last element and returns that element (changes length of array)
}
}
return A;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment