What's wrong with my code? Isn't it the same with the first solution?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
function findLongestWordLength(str) {
let words=str.split("");
let max = 0;
for (let i=0; i<words.length; i++){
  if(words[i].length > max){
    max = words[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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44

Challenge: Find the Longest Word in a String

Link to the challenge:

pay attention to the way you split the string.

1 Like

A minor mistake can break your perfect code! Check closely the delimiter used for splitting!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.