Whats wrong with this Find the Longest Word in a String

Whats wrong with this Find the Longest Word in a String
0.0 0

#1

Tell us what’s happening:

Your code so far


function findLongestWordLength(str) {
  let arr = str.split(" ");
  let max = 0;
  for(let i =0 ; i < arr.length ; i++){
    if(arr[i].length > max){
      max = arr[i].length ;
    }
  }
  return max;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string/


#2

Hi @amit2kk

You’re code works for me when I run it (using chrome). Make a copy of the code, then click the “Reset All Code” button and try running the tests again.


#3

still not running. i guess some logic is missed out. code is running but not desired output


#4

Try closing your browser or refreshing the page (F5). Also, make sure you are not using Internet Explorer or Edge browser, as those have problems working with the FCC site. Use a browser like Chrome.