Can someone help me to find an error?
Your code so far
function findLongestWord(str) {
str = str.split(' ');
var maxLength = 0;
var indexMaxLength = 0;
for (var i = 0;i<str.length;i++){
if(str[i].length>maxLength){
maxLength=str[i].length;
indexMaxLength=i;
}
}
return indexMaxLength;
}
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/62.0.3202.94 Safari/537.36
.
Link to the challenge: