Intended for beginners:
Input: ['Green', 'red', 'blue'];
Output: 'red' - Minimum length String.
function minLenString(arr) {
return arr.reduce((a, b) => a.length <= b.length ? a : b);
}
To find min length in array.
function minLenString(arr) {
return Math.min(...arr.map(item => item.length));
}
Thanks.
Top comments (2)
Two things I'm going to suggest here:
If this is targeted for beginners, the goal would to be to make them as least confused as possible.
Thanks @jzombie, Thatz a typo. I will update.