Ah yes, woods, I was looking at the trees. Still, to carry on with the concise style:
```js const minMax = (arr=[]) => arr.reduce( ([min=Infinity, max=-Infinity], curr) => [ min < curr ? min : curr, max > curr ? max : curr ], [] ) ``` On Mon, 2 Oct 2017 at 16:55 Xavier Stouder <[email protected]> wrote: > Same for Michael. Useless to not use a reducer instead of Math.min and > Math.max if it has worth performance. > > Just to be clear, the fact is that your function approximately costs: > Math.min: one loop over the array > Math.max: one loop over the array > Math.minMax: one loop over the array > > Math.minMax do in one pass what Math.min and Math.max do in two passes. > That's the key point. > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

