reduceWhich
Returns the minimum/maximum value of an array, after applying the provided function to set the comparing rule.
- Use
Array.prototype.reduce()in combination with thecomparatorfunction to get the appropriate element in the array. - Omit the second argument,
comparator, to use the default one that returns the minimum element in the array.