Tell us what’s happening:
Help me with this. Is there any problem? Also, when I am running the same code on VS code by adding a ‘console.log’ statement to the “findLongestWordLength” function it isn’t logging the correct result in some cases. The function isn’t returning anything.
Your code so far
const findLongestWordLength = (sentence) =>{
const words = sentence.split("");
let longWord = 0;
for (let i = 0; i<words.length; i++){
if(words[i].length>longWord){
longWord = words[i].length;
}
}
return longWord;
};
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/145.0.0.0 Safari/537.36 Edg/145.0.0.0
Challenge Information:
Build a Longest Word Finder App - Build a Longest Word Finder App