Find the Longest Word in a String

preview_player
Показать описание
function findLongestWordLength(str) {
// split the string into individual words

// words only has 1 element left that is the longest element
return words[0].length;
}

// if words has multiple elements, remove the first element
// and recursively call the function
words[0].length,
);
}

findLongestWordLength("The quick brown fox jumped over the lazy dog");
Рекомендации по теме