Answers for "find longest and smallest string in array javascript"

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
1

find smallest length string in an array js

var arr = ["aaaa", "aa", "aa", "aaaaa", "a", "aaaaaaaa"];

console.log(
  arr.reduce((a, b) => a.length <= b.length ? a : b)
)
Posted by: Guest on August-18-2020
0

find smallest length string in an array js

var arr = ['cats', 'giants', 'daughters', 'ice'];
var min = Math.min(...arr.map(({ length }) => length));
console.log(min);
Posted by: Guest on August-18-2020

Code answers related to "find longest and smallest string in array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language