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]
Please see this short solution below. I hope it helps:
var arr = ['cats', 'giants', 'daughters', 'ice']; arr.sort(); // ice, cats, giants, daughters var shortest_element = arr[0]; // ice