Find the Longest Word in a String (code works, but error message exists)

Find the Longest Word in a String (code works, but error message exists)
0

#1

Tell us what’s happening:

My code works and I get the success pop up, but the code input section does show an error (missing semi-colon) on my sort function. I don’t see any errors, and everything functions properly. Am I missing something here?

Your code so far

function findLongestWord(str) {
  var strArray = str.split(" ");
  strArray.sort(function(a,b){return b.length-a.length});
  return strArray[0].length;
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:


#2
function findLongestWord(str) {
  var strArray = str.split(" ");
  strArray.sort(function(a,b){return b.length-a.length;}); // semi-colon after a.length
  return strArray[0].length;
}

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

#3

Oh ya, that makes sense now that I see it. Thanks