Forked from anonymous/bonfire-falsy-bouncer?solution=function%20bouncer(arr)%20%7B%0A%20%20%2F%2F%20Don%27t%20show%20a%20false%20ID%20to%20this%20bouncer.%0A%20%20return%20arr.filter(function(value)%20%7B%0A%20%20%20%20return%20value%3Ftrue%3Afalse%3B%0A%20%20%7D)%3B%0A%7
Created
November 30, 2015 10:21
-
-
Save srkama/76a4c07cb5773d88127f to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/srkama '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: @srkama | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer?solution=function%20bouncer(arr)%20%7B%0A%20%20%2F%2F%20Don%27t%20show%20a%20false%20ID%20to%20this%20bouncer.%0A%20%20return%20arr.filter(function(value)%20%7B%0A%20%20%20%20return%20value%3Ftrue%3Afalse%3B%0A%20%20%7D)%3B%0A%7D%0A%0Abouncer(%5B7%2C%20%22ate%22%2C%20%22%22%2C%20false%2C%209%5D)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function bouncer(arr) { | |
// Don't show a false ID to this bouncer. | |
return arr.filter(function(value) { | |
return value?true:false; | |
}); | |
} | |
bouncer([7, "ate", "", false, 9]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment