Category: Uncategorised

Basic Algorithm Scripting – Find the Longest Word in a String

Basic Algorithm Scripting – Find the Longest Word in a String

Problem Statement ( Find The Longest Word in a String ) : Return the length of the longest word in the provided sentence. Your response should be a number. Solution : function findLongestWord(str) { var s = str.split(” “); var max = s.sort(function(a,b){ return b.length – a.length; }); return max[0].length; } Explanation : The task …

+ Read More

www.000webhost.com