Tell us what’s happening:
Hi all,
I tested my solution in Chrome console and it returned the correct result every time. However it is not passing any of the tests on the FreeCodeCamp side. It is returning the following:
assignment to undeclared variable i
Any direction is appreciated. I have tested it with the strings for the tests it must pass and in console it returns the correct answers.
Your code so far
function findLongestWordLength(str) {
var strSplit = str.split(' ');
var longestWord = strSplit[0].length;
for (i = 0; i < strSplit.length; i++) {
if (longestWord < strSplit[i].length) {
longestWord = strSplit[i].length;
}
} return longestWord;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
I am logged into FreeCodeCamp in Firefox but using chrome console to test code.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge: