Last active
May 10, 2024 00:00
-
-
Save sukima/ba91ca5ef64d61edf03e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findLongestWord(str) { | |
| return Math.max(...str.split(' ').map(val => val.length)); | |
| } | |
| findLongestWord('The quick brown fox jumped over the lazy dog'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findLongestWord(str) { | |
| var lengths = str.split(' ').map(function(val) { | |
| return val.length; | |
| }); | |
| return Math.max.apply(Math, lengths); | |
| } | |
| findLongestWord('The quick brown fox jumped over the lazy dog'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment