Chrome Extension

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

Do you know, you can create and search your own code snippets on Devsheet. Store your code on cloud using devsheet and search using its chrome extension. Is it look cool?

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?
0 Comments
Never leave your website again in search of code snippets by installing our chrome extension.