Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IAmAnubhavSaini/e0041c6c2a2404d7d6c8 to your computer and use it in GitHub Desktop.
Save IAmAnubhavSaini/e0041c6c2a2404d7d6c8 to your computer and use it in GitHub Desktop.
function findLongestWord(str) {
return str.split(' ').sort(function(a, b){ return a.length - b.length;}).pop().length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");
findLongestWord("What if we try a super-long word such as otorhinolaryngology") ;
findLongestWord("What is the average airspeed velocity of an unladen swallow");
findLongestWord("Google do a barrel roll");
findLongestWord("May the force be with you");
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