Tell us what’s happening:
would anyone know how to make this code work?
i feel like the map function combined with the lenght and Math.max should be able to resolve this problem.
Your code so far
function findLongestWordLength(str) {
let result = [str.split(' ')];
let x = result.map(function (){
return Math.max (result.length);
});
return (x);
}
console.log(result);
console.log(findLongestWordLength("The quick brown fox jumped over the lazy dog"));
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string