Files
30-seconds-of-code/test/reduceWhich/reduceWhich.js
2018-02-04 17:38:39 +02:00

3 lines
143 B
JavaScript

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