Skip to content

Instantly share code, notes, and snippets.

@denmch
Created December 22, 2015 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denmch/18cdcf9c9de0c22e1629 to your computer and use it in GitHub Desktop.
Save denmch/18cdcf9c9de0c22e1629 to your computer and use it in GitHub Desktop.
"Remove all falsy values from an array."
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