Hi guys,
this code works in VS Code but not in FCC and I don’t get why.
function findLongestWordLength(str) {
let words = str.split(" ");
let result = "";
for (word of words) {
if (word.length > result.length) {
result = word;
}
}
return result.length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36
.
Challenge: Find the Longest Word in a String
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string