Skip to content

Instantly share code, notes, and snippets.

@jgresalfi
Created September 19, 2016 00:40
Show Gist options
  • Save jgresalfi/eae7921ecde8826f6ddbeba09e2052e8 to your computer and use it in GitHub Desktop.
Save jgresalfi/eae7921ecde8826f6ddbeba09e2052e8 to your computer and use it in GitHub Desktop.
Remove all falsy values from an array.
function bouncer(arr) {
var newArr = arr.filter( function(el) {
if (el) {
return el;
}
});
return newArr;
}
bouncer([7, "ate", "", false, 9]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment