Created
December 10, 2015 05:51
-
-
Save joePichardo/9c45bdd2a91a74936d25 to your computer and use it in GitHub Desktop.
Return the remaining elements of an array after chopping off n elements from the head.
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
// Bonfire: Slasher Flick | |
// Author: @joepichardo | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function slasher(arr, howMany) { | |
// it doesn't always pay to be first | |
//howMany is the number we must remove from our array of arr | |
//if howMany is larger than arr length return empty string | |
//else return array by the method slice | |
// we start at index "howMany" and goes all the way to the end or (arr.length) | |
if(howMany >= arr.length){ | |
return []; | |
} else { | |
return arr.slice(howMany, arr.length); | |
} | |
} | |
slasher([1, 2, 3], 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment