Here’s my solution without any split/map/reduce method, feedback appreciated for further optimization of code, is the current code much perform much worse without above mentioned methods?

function findLongestWordLength(str) {
let max = 0;
let i = 0;
while (str[i] && i < str.length){ //restrict to str length range
let count = 0;
while(str[i] && str[i] !== ' '){ //counting a valid word(defined by non space)
i++;
count++;
}
if (count > max){ //check if counted word exceed the current max, if yes replace
max = count;
}
while(str[i] && str[i] === ' '){ //skipping spaces
i++;
}
}
return max;
}