Skip to content

Instantly share code, notes, and snippets.

@mattnwa
Forked from anonymous/bonfire-slasher-flick.js
Created December 3, 2015 21:51
Show Gist options
  • Save mattnwa/278b7db3f3b2b2e35e42 to your computer and use it in GitHub Desktop.
Save mattnwa/278b7db3f3b2b2e35e42 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mattnwa 's solution for Bonfire: Slasher Flick
// Bonfire: Slasher Flick
// Author: @mattnwa
// 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
if (howMany < 1) {
return arr;
} else {
return arr.splice(howMany, arr.length);
}
}
slasher([1, 2, 3], 2);
slasher([1, 2, 3], 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment