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: