Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/34073976a4d38fe197b4 to your computer and use it in GitHub Desktop.
Save anonymous/34073976a4d38fe197b4 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/duggiemitchell 's solution for Bonfire: Falsy Bouncer
// Bonfire: Falsy Bouncer
// Author: @duggiemitchell
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
var falsyArr = [];
var trueArr = arr.filter(Boolean);
return (trueArr);
}
console.log(bouncer([7, "ate", "", false, 9]));
@duggiemitchell
Copy link

After spending an hour on this I find that Boolean constructor is also a function that returns either true for 'thruthy' and false for 'falsy' argument. I just saved about 5 lines of code thanks @elado for your blog post simplifying what seemed at first more difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment