Created
April 7, 2016 04:31
-
-
Save mmloveaa/b318c1799c7fd28b935668ec5dd6a2e8 to your computer and use it in GitHub Desktop.
FCC - slasher
This file contains hidden or 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 slasher(arr, howMany) { | |
console.log(arr.splice(0,howMany)); | |
console.log(arr) | |
return arr.slice(howMany); | |
// it doesn't always pay to be first | |
// if(howMany > arr.length){ | |
// return []; | |
//} else if (howMany===0){ | |
// return arr; | |
//} else { | |
// return arr.slice(howMany, howMany+1); | |
//} | |
} | |
slasher([1, 2, 3], 2); | |
// slasher([1, 2, 3], 0); | |
// slasher([1, 2, 3], 2) should return [3]. | |
// slasher([1, 2, 3], 0) | |
// should return [1, 2, 3]. | |
// slasher([1, 2, 3], 9) should return []. | |
// slasher([1, 2, 3], 4) should return []. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment