Created
December 4, 2015 21:01
-
-
Save clive-bunting/80e3eac0825e1026412c to your computer and use it in GitHub Desktop.
Bonfire: Drop it
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
| // 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