Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Find the Longest Word in a String

function findLongestWordLength(str) {

  let arr = str.split(' '); 
  let maxLength = 0;

  for (let i = 0; i < arr.length; i++){
    if (arr[i].length >= maxLength){
      maxLength = arr[i].length;
    }
  } 

  return maxLength;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Find #Longest #Word #String
ADD COMMENT
Topic
Name
9+2 =