java-script:reduce:find-longest-word-from-a-string
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java-script:reduce:find-longest-word-from-a-string [2023/08/07 18:03] – odefta | java-script:reduce:find-longest-word-from-a-string [2025/01/02 18:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| < | < | ||
| - | The function | + | The function uses the **reduce** method on the array of words to find the longest word. The reduce method takes a callback function that compares the length of the current word to the length of the longest word found so far (maxWord): |
| <code javascript> | <code javascript> | ||
| .reduce((maxWord, | .reduce((maxWord, | ||
java-script/reduce/find-longest-word-from-a-string.1691431425.txt.gz · Last modified: (external edit)
