Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Find greatest length if letters in a string

function findLongestWordLength(str) {
  let words = str.split(' ');
  let maxLength = 0;

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

  return maxLength;
}
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Find #greatest #length #letters #string
ADD COMMENT
Topic
Name
4+8 =