-
Notifications
You must be signed in to change notification settings - Fork 212
Open
Description
There's a mistake in CH3 > Array methods > Finding elements
The mistake is in saying that the function “returns the element” when the condition is met. In this code, the callback function does not return the element itself. It returns the result of the comparison e === 6 or e === 10, which is a boolean value (true or false). The function’s job is only to tell find() whether the current element matches the condition.
The correct explanation is that the callback function returns true when the element satisfies the condition, and false otherwise. When find() receives true from the callback, it stops iterating and returns the corresponding element from the array. If the callback never returns true, then find() returns undefined.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels