Tell us what’s happening:
I think I understand the basic structure of this project, but somehow, test cases 4, 8, and 9 do not resolve. They seem only to hit the first word that is longer before the longest word in the sentence. I can output each array[i].length in another array, but I do not understand what JavaScript methods to use to compare each of the word’s lengths in that array. I would appreciate a little guidance here.
Thanks!
Your code so far
function findLongestWordLength(string){
const array = string.split(" ")
console.log(array)
let wordLength = []
for(let i = 0; i < array.length; i++) {
if(array[i].length > array.length - array[i].length) {
return array[i].length
}
}
}
console.log(findLongestWordLength("What if we try a super-long word such as otorhinolaryngology"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Challenge Information:
Build a Longest Word Finder App - Build a Longest Word Finder App