Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2015 16:30
Show Gist options
  • Save anonymous/54c743ad11522e62a69d to your computer and use it in GitHub Desktop.
Save anonymous/54c743ad11522e62a69d to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/bskydive 's solution for Bonfire: Falsy Bouncer
// 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