Skip to content

Instantly share code, notes, and snippets.

@bflannery
Created December 21, 2016 18:35
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 bflannery/2697b06edd176ab8353b8f10adf69bcc to your computer and use it in GitHub Desktop.
Save bflannery/2697b06edd176ab8353b8f10adf69bcc to your computer and use it in GitHub Desktop.
// Return the remaining elements of an array after chopping off n elements from the head.
// The head means the beginning of the array, or the zeroth index.
// (non-mutative)
function slasher(arr, howMany) {
return arr.slice(howMany);
}
console.log(slasher([1, 2, 3], 2));
console.log(slasher([1, 2, 3], 0));
console.log(slasher(["burgers", "fries", "shake"], 1));
console.log(slasher([1, 2, 3], 4));
console.log(slasher([1, 2, 3], 9));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment