Tell us what’s happening:
Now I turn the string to array, after this i should check for length each element for length, but how I can find most long element among them? Is it by var max = Math.max.apply(null, arr);
?
Your code so far
function findLongestWordLength(str) {
let arr = str.split(" ");
console.log(max);
return str.length;
}
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/69.0.3497.100 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