Tell us what’s happening:
Hi! findLongestWordLength("What if we try a super-long word such as otorhinolaryngology") should return 19. is the only one that is not checked. Can you help me pls? Mozilla Console says that return is not in the function but I think it is!!
Your code so far
function findLongestWordLength(str) {
let arr = str.split(" ");
let nums = [];
for (let i = 0; i < arr.length; i++) {
nums.push(arr[i].length);
nums.sort();
}
return nums[nums.length - 1];
}
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:109.0) Gecko/20100101 Firefox/117.0
Challenge: Basic Algorithm Scripting - Find the Longest Word in a String
Link to the challenge: