Search code snippets, questions, articles...

Find the shortest string in array

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

console.log(
  arr.reduce(function(a, b) {
    return a.length <= b.length ? a : b;
  })
)
// result a

Find the shortest string in array

Search Index Data (The code snippet can also be found with below search text)

Find the shortest string in array
Was this helpful?
1 Comments

Nice work @matheusmurata

Programming Feeds
Learn something new everyday on Devsheet