Find the Longest Word in a String(Basic Algo)

function findLongestWordLength(str) {
  let maxLength = 0;
  let result = '';
  let splitted = str.split(" ");
  for(i = 0; i < splitted.length; i++){
    if(splitted[i].length > maxLength){
      maxLength = splitted[i].length;
      result = maxLength;
  return result;
 console.log(findLongestWordLength("The quick brown fox jumped over the lazy dog"));

Pls Whats wrong with my code?

Make sure you always declared variables before using them. Your for loop declaration has an undefined i variable. You can see that in the console message.