Wrong return value (CH3, Array methods, Finding elements)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 65/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- documentation
Research direction
Find the CH3 > Array methods > Finding elements passage described in the issue and review its explanation of the callback and find(). Correct the wording so it distinguishes the callback's boolean result from the element returned by find(), including the undefined case when no match is found.
Written by the indexing model from the issue text.
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.
- Dominant language
- HTML
- Stars
- 370
- Forks
- 218
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PacktPublishing/JavaScript-from-Beginner-to-Professional
-
Difficulty 1/5 Under an hour Newbie friendliness 5/100
PacktPublishing/JavaScript-from-Beginner-to-Professional#10 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
PacktPublishing/JavaScript-from-Beginner-to-Professional#9 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
PacktPublishing/JavaScript-from-Beginner-to-Professional#6 · 1 comment ·
All issues in PacktPublishing/JavaScript-from-Beginner-to-Professional
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·