Find the Longest Word Not Working

Find the Longest Word Not Working
0.0 0

#1

Tell us what’s happening:
made it work in visual code… i don’t understand why i wont pass the test… any help please… thank you for reading…

Your code so far

function findLongestWord(str) {
  strSplit = str.split(' ');
  strNum = [];
  strSplit.forEach(function(item){strNum.push(item.length);});
  console.log(strNum.reduce(function(a,b){return Math.max(a,b);}));
}

  
  findLongestWord("The quick brown fox jumped over the lazy dog");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36.

Link to the challenge:


#2

Your function should return the result, not print in the console.


#3

Thank you for the reply i got it to work with return. i really appreciate it.