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.
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 === 6ore === 10, which is a boolean value (trueorfalse). The function’s job is only to tellfind()whether the current element matches the condition.The correct explanation is that the callback function returns
truewhen the element satisfies the condition, andfalseotherwise. Whenfind()receivestruefrom the callback, it stops iterating and returns the corresponding element from the array. If the callback never returnstrue, thenfind()returnsundefined.