Created
December 22, 2015 00:02
-
-
Save denmch/18cdcf9c9de0c22e1629 to your computer and use it in GitHub Desktop.
"Remove all falsy values from an array."
This file contains 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 bouncer(arr) { | |
// Don't show a false ID to this bouncer. | |
function falsy(value) { | |
return Boolean(value); | |
} | |
return arr.filter(falsy); | |
} | |
bouncer([7, "ate", "", false, 9]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment