How can i find the shortest string in javascript array with different count of array elements? I used
var min = Math.min(arr[0].length,arr[1].length,arr[2]
You could use Array.prototype.reduce
Array.prototype.reduce
const arr = ['small', 'big', 'yuge'] const shorter = (left, right) => left.length <= right.length ? left : right console.log( arr.reduce(shorter) )