Tell us what’s happening:
I am trying to call Math.max in a .reduce to return the largest number out of an array. Calling ‘Math’ doesn’t light up, what could be the problem?
Your code so far
function findLongestWord(str) {
var b= str.split(" ");
var myArray= [];
for (var i=0; i<b.length; i++)
{myArray.push( (b[i].length));}
myArray.reduce(function(acc, item) {
return Math.max(acc, item);}, -Infinity);}
//return myArray;}
findLongestWord("The quick brown fox jumped over the lazy dog");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299
.
Link to the challenge:
https://www.freecodecamp.org/challenges/find-the-longest-word-in-a-string