I\'m trying to find the longest word in a string, but it continually returns the length of the first word. Any ideas?
Here\'s my code:
function findL
Try using the following code sample:
function findLongestWord(str){ var arr=[]; arr=str.split(' '); arr=arr.sort(function(a,b){ return b.length-a.length; }); var st=arr[0]; return st.length; } findLongestWord("The quick brown fox jumped over the lazy dog");