item with least string length in array javascript code example
Example 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)
)
Example 2: 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);