LearnFrenzy
Sign in Take a free test

Array Methods · Array Methods MCQ · Question 2

What does filter keep? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 2 Back to Exercise

Which elements does arr.filter(fn) keep?

  • A Those for which fn returns exactly true
  • B Those for which fn returns a truthy value Correct
  • C The first element only
  • D Those for which fn returns undefined
Correct Answer: Option B

The callback's result is converted to a boolean. That is why filter(Boolean) removes all falsy values.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links