i'm trying to print the longest word from a string and to ignore the number, so even though the number is the longest, it will print the longest word.
let userInput = "print the longest word 3372838236253 without number";
function longestWord(userInput) {
let x = userInput.split(" ");
let longest = 0;
let word = null;
x.forEach(function(x) {
if (longest < x.length) {
longest = x.length;
word = x;
}
});
return word;
}
console.log(longestWord(userInput));