What is am i missing

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

  **Your code so far**

function findLongestWordLength(str) {
let i = str.split(' ')
let logan = 0;
for(let w = 0; w < str.length; w++){
  if(i[w].length > logan){
    logan = i[w].length
  }
}
return logan;
}

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/92.0.4515.131 Safari/537.36 Edg/92.0.902.67

Challenge: Find the Longest Word in a String

Link to the challenge:

Do you want that loop to happen str.length times, or i.length times?

Yeah, that for loop will run the same number of times as the number of characters in str, not the number of elements in i.

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