Find the Longest Word in a String
Return the length of the longest word in the provided sentence.
Your response should be a number.
SOLUTION:
function findLongestWordLength(str) {
let arr = str.split(" ");
// console.log(arr)
let result = arr[0];
for(let i=0; i<arr.length;i++) {
if(result.length < arr[i].length) {
result = arr[i]
}
}
return result.length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
console.log(findLongestWordLength("The quick brown fox jumped over the lazy dog"))
Click here to go to the original link of the question.