49.8k views
4 votes
Create the code that will find

the longest word of the given
string. You are not allowed to
use split() method

(python)

1 Answer

5 votes

Answer:

function findLongestWord(str) {

var longestWord = str.split(' ').sort(function(a, b) { return b.length - a.length; });

return longestWord[0].length;

}

findLongestWord(InputHere);

Step-by-step explanation:

Replace InputHere with the input

User Saurav Kumar
by
5.5k points