Bonfire Slasher Flick - GJSmith3rd/FreeCodeCamp-BootCamp GitHub Wiki
Contact me
Gilbert Joseph Smith III
Github | FreeCodeCamp | CodePen | LinkedIn | Blog/Site | E-Mail
Details
- Difficulty: 1/5
Return the remaining elements of an array after chopping off n elements from the head.
Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.
Useful Links
Problem Script:
function slasher(arr, howMany) {
// it doesn't always pay to be first
return arr;
}
slasher([1, 2, 3], 2);
Explanation:
We have to take an array and delete as many elements from the beginning as stated by the second parameter.
Hint: 1
It can be done in one line with slice.
Hint: 2
If you want you can try to use splice but slice is enough.
Hint: 3
Really? Splice by the number of the second parameter.
My code:
function slasher(arr, howMany) {
return arr.slice(howMany);
}
My Code Explanation:
Slice the array by the about of the second parameter.