Files
30-seconds-of-code/test/reduceWhich/reduceWhich.js
2018-08-02 13:49:33 +03:00

4 lines
146 B
JavaScript

const reduceWhich = (arr, comparator = (a, b) => a - b) =>
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
module.exports = reduceWhich;