Skip to content

Instantly share code, notes, and snippets.

@brainyfarm
Created June 21, 2016 14:41
Show Gist options
  • Save brainyfarm/96584063db21cec6f85c96b899ef5a0f to your computer and use it in GitHub Desktop.
Save brainyfarm/96584063db21cec6f85c96b899ef5a0f to your computer and use it in GitHub Desktop.
Olawale/FreeCodeCamp Algorithm: Slasher Flick
function slasher(arr, howMany) {
// Keep looping as long as howMany is greater than 0
while(howMany > 0){
// Remove the first item from the array
arr.shift(); // arr.shift() mutates the array
// Decrement howMany
howMany --;
}
// Return the slashed array.
return arr;
}
slasher([1, 2, 3], 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment