Three Ways to Find the Longest Word in a String in JavaScript
Sonya Moisset

function findLongestWord(str) {
 // Get an array with strings
 var arraystr = str.split(‘ ‘);
 // Get an array with strings’s lengths
 var arraylength =, index, array){return item.length;});
 // find the max value
 return Math.max.apply(null,arraylength);

findLongestWord(“The quick brown fox jumped over the lazy dog”);

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.