Answers for "longest and lowest string in js"

6

find length of longest string in array javascript

const findLongest = words => Math.max(...(words.map(el => el.length)));

// Example
findLongest(['always','look','on','the','bright','side','of','life']);  // 6
Posted by: Guest on July-02-2020
4

javascript find the longest word 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;
  }
  
  
findLongestWordLength("The quick brown fox jumped over the lazy dog");

// 6
Posted by: Guest on June-09-2020

Code answers related to "longest and lowest string in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language