Tell us what’s happening:
ok. so this works. everywhere except on the page for the problem. (“May the force be with you”) returns 5 in VS Code + nodes.js console, online js compilers. but not here. frustrated!
Your code so far
function findLongestWord(str) {
var arr = str.split(" ");
var numArr = [];
for (i = 0; i < arr.length; i++)
{
console.log(arr[i].length + " = " + arr[i]);
numArr.push(arr[i].length);
}
for (a = 0; a < arr.length; a++)
{
if (numArr[a] > highest)
{
highest = numArr[a];
}
}
return highest;
}
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/66.0.3359.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/find-the-longest-word-in-a-string