You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Islam Ibakaev edited this page Apr 26, 2016
·
1 revision
Details
Return the length of the longest word in the provided sentence.
Your response should be a number.
Elegant solution
function findLongestWord(str) {
return Math.max.apply(null, str.split(' ').map(function(el) {return el.length;}));
}
findLongestWord('The quick brown fox jumped over the lazy dog'); // returns 6