Tell us what’s happening:
// I dont know why its not returning req answer . some cases are getting passed while some are not please help.
Your code so far
function findLongestWordLength(str) {
var str3;
var str2=str.split(" ");
for(var i=0;i<str2.length-1;i++){
if(str2[i+1].length>=str2[i].length){
str3=str2[i+1];
}
else str3=str2[i];
}
return str3.length;
}
console.log(findLongestWordLength("The quick brown fox jumped over the lazy dog"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string/