Tell us what’s happening:
Your code so far
function findLongestWordLength(str) {
let arr1 = str.split(" ").reverse();
let arr2 = str.split(" ");
let final = 0;
for(let i = 0;i<arr1.length;i++){
if(arr1[i].length>arr2[i].length){
final = arr1[i];
}
}
return console.log(final.length);
}
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; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Find the Longest Word in a String
Link to the challenge: