I dont understand this and am not able to find my mistake please help

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

  **Your code so far**

function findLongestWordLength(str) {
let words = str.split('');
let maxLength = 0;
for (let i = 0; i < words.length; i++) {
  if (words[i].length > maxLength) {
    maxLength = words[i].length;
  }
}
return maxLength;
}
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/93.0.4577.82 Safari/537.36

Challenge: Find the Longest Word in a String

Link to the challenge:

have you tried using console.log to check the values of the various variables you have inside the function?

I’d be especially interested to know what the array words is storing.

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