Find the length of a string please help I'm stuck

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

help me find length of a string
Your code so far


function findLongestWordLength(str) {
const words = str.split(" ");

if (words.lenth == 1) {
  return words[0].length;
}
return Math.max(
  words[0].length,
  findLongestWordLength(words.slice(1).join(" "))
);
}

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/95.0.4638.69 Safari/537.36

Challenge: Find the Longest Word in a String

Link to the challenge:

Hi @siba45 !

You have a spelling error here.

When you fix that it will pass.

But this is also one of the guide post solutions.
So, I would encourage you to try and come up with your own solution.

Coming up with your own solutions will help with your problem solving :grinning:

Hope that helps!

1 Like