Skip to content

Instantly share code, notes, and snippets.

@sukima
Last active May 10, 2024 00:00
Show Gist options
  • Save sukima/ba91ca5ef64d61edf03e to your computer and use it in GitHub Desktop.
Save sukima/ba91ca5ef64d61edf03e to your computer and use it in GitHub Desktop.
function findLongestWord(str) {
return Math.max(...str.split(' ').map(val => val.length));
}
findLongestWord('The quick brown fox jumped over the lazy dog');
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