Can't figure this one out

Hi, I don’t understand why this wouldn’t work. I appreciate if someone could explain. Thanks in advance.

Your code so far

function findLongestWordLength(str) {
const longestWord = str.split(" ").reduce((num, nextNum) => {
  return nextNum.length > num.length ? nextNum.length : num.length;

return longestWord;

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Find the Longest Word in a String

Link to the challenge:

You are almost there but you have one issue that is keeping you from passing. Take a look at the console below where you type in the code. You should see an error there telling you what the issue is.

I think one thing that may help you is if you use better variable names. For example, in the reducer you are using num and nextNum. I think if you make these a little more accurate it might help you see the issue.

1 Like

What type of value are you returning in your reduce? What type of value does your reduce function assume that num is?

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