Created
December 6, 2015 16:30
-
-
Save anonymous/54c743ad11522e62a69d to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/bskydive 's solution for Bonfire: Falsy Bouncer
This file contains hidden or 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
| // Bonfire: Falsy Bouncer | |
| // Author: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function bouncer(arr) { | |
| function filtMe(value){ | |
| var result=false; | |
| //NaN,undefined,null check only this way | |
| if (value) {result=(!value.toString().toLowerCase().includes('false') & value.toString().length>0);} | |
| return result; | |
| } | |
| return arr.filter(filtMe); | |
| } | |
| bouncer([false, null, 0, NaN, undefined, ""]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment