javascript
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
Was this helpful?
Similar Posts
- Find the minimum value from an array javascript
- Find the maximum value from an array using Javascript
- Lodash - Find item index from array by searching from the end
- Array.find() - get the very first element satisfy a condition Javascript
- Find the index of Max value in an array using Javascript
- Simplest Way to Find the Smallest Number in an Array using JavaScript
- Find the Third Smallest Number in an Array using Javascript