Last active
December 14, 2016 15:05
-
-
Save Hoxtygen/050e1100c1a72ceb99a4516923c9dcc2 to your computer and use it in GitHub Desktop.
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. | |
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