Skip to content

Instantly share code, notes, and snippets.

@clive-bunting
Created December 4, 2015 21:01
Show Gist options
  • Select an option

  • Save clive-bunting/80e3eac0825e1026412c to your computer and use it in GitHub Desktop.

Select an option

Save clive-bunting/80e3eac0825e1026412c to your computer and use it in GitHub Desktop.
Bonfire: Drop it
// Bonfire: Drop it
// Author: @clive-bunting
// Challenge: http://www.freecodecamp.com/challenges/bonfire-drop-it
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function drop(arr, func) {
if (arr.length === 0 || func(arr[0])) {
return arr;
}
arr.shift();
return drop(arr, func);
}
drop([1, 2, 3], function(n) {return n < 3; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment