Tell us what’s happening:
Anyone can help to fix my code? My logic is wrong?
Your code so far
function findLongestWordLength(str) {
let count = 0;
let length = [];
for (let i = 0; i < str.length; i++) {
if (str[i]>="a" && str[i]<="z" || str[i]>="A" && str[i]<="Z") {
count++;
}
else {
length.push(count);
count = 0;
}
}
return Math.max(length);
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
.
Link to the challenge: