Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonfire: Falsy Bouncer #3883

Closed
ghost opened this issue Oct 25, 2015 · 2 comments
Closed

Bonfire: Falsy Bouncer #3883

ghost opened this issue Oct 25, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 25, 2015

Challenge Bonfire: Falsy Bouncer has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function bouncer(arr) {
  return arr.filter(isTruthy);
}

function isTruthy(a) {
  arr = [false, null, 0, "", undefined, NaN];
  for (i = 0; i < arr.length; i++) {
    if (arr[i] === a) return false;
  }
  return true;
}

bouncer([false, null, 0, NaN, undefined, ""]);
@bugron
Copy link
Contributor

bugron commented Oct 25, 2015

@yielder thanks for posting this issue!
The problem is that NaN === NaN returns false. To check if the value is NaN use isNaN.
If you have problems with your code, please, post a message in our Gitter chat room first, thanks.


Please review the Guidelines for Contributing, thank you!.


@ghost
Copy link
Author

ghost commented Oct 25, 2015

@bugron Thanks for your answer. I'll notice that next time.

@ghost ghost closed this as completed Oct 25, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant