Tell us what’s happening:
Not sure why its not passing. I put in VSCode and ran in web and output was as needed.
Your code so far
function findLongestWordLength(str) {
str = str.split(" ")
for (i=0; i<(str.length-1) ; i){
let wordOne = str[i].split("")
let wordTwo = str[i+1].split("")
if (wordOne.length >= wordTwo.length){
str.splice(i+1,1)
} else {
str.splice(i,1)
} } longNum = str[0].split("")
return longNum.length }
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36
.
Challenge: Find the Longest Word in a String
Link to the challenge: