Skip to content

Instantly share code, notes, and snippets.

@Hoxtygen
Last active December 14, 2016 15:05
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 Hoxtygen/050e1100c1a72ceb99a4516923c9dcc2 to your computer and use it in GitHub Desktop.
Save Hoxtygen/050e1100c1a72ceb99a4516923c9dcc2 to your computer and use it in GitHub Desktop.
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var filtered = [];
filtered = arr.filter(function (x) {
return x !==undefined && x !==null & x!==false && x === NaN && x !==0 && x !== "";
});
return filtered;
}
bouncer([7, "ate", "", false, 9]);
// bouncer([7, "ate", "", false, 9]) should return [7, "ate", 9].
// bouncer(["a", "b", "c"]) should return ["a", "b", "c"].
// bouncer([1, null, NaN, 2, undefined]) should return [1, 2].
// bouncer([false, null, 0, NaN, undefined, ""]) should return [].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment