Hi here! I’m new, and I’ve written a new solution (I think) to this problem.
The thing is that the system give me error when I try to run the test, and don’t know why because the console give me the right number.
function findLongestWordLength(str) {
let palabras = str.split(" ");
let palabritasarr = [];
palabras.forEach(funcion);
function funcion(item){
let x = item.length;
palabritasarr.push(x)
}
var max = Math.max(...palabritasarr);
return console.log(max)
}
findLongestWordLength("What is the average airspeed velocity of an unladen swallow");
function findLongestWordLength(str) {
let palabras = str.split(" ");
let palabritasarr = [];
palabras.forEach(funcion);
function funcion(item){
let x = item.length;
palabritasarr.push(x)
}
var max = Math.max(...palabritasarr);
return (max);
}
findLongestWordLength("What is the average airspeed velocity of an unladen swallow");