freeCodeCamp: Wrong filter description

Describe the Issue

This page incorrectly says that filter keeps elements when the callback returns the Boolean value true. This is incorrect, any element that results in a truthy return value is retained.

Affected Page

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array

Expected behavior

The line:

filter calls a function on each element of an array and returns a new array containing only the elements for which that function returns true.

Should be replaced with the line:

filter calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns true if passed to the Boolean() constructor.

Screenshots

No response

System

All

Additional context

The file to edit: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array.md

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (22 by maintainers)

Most upvoted comments

Yep that should be fine.

I’ll go ahead and open this up to contribution, then.

I think we may be splitting hairs on this.

filter calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns true when passed to the Boolean() constructor.