Make it clear that the firstTwoMax() function only cares about the first 2 arguments

This commit is contained in:
PyGeek03
2019-09-03 14:44:31 +10:00
parent b398897535
commit 8bcf05a800
2 changed files with 3 additions and 3 deletions

View File

@ -13,5 +13,5 @@ const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
```js
const firstTwoMax = ary(Math.max, 2);
[[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
[[2, 6, 'a'], [6, 4, 8], [10]].map(x => firstTwoMax(...x)); // [6, 6, 10]
```

View File

@ -5,5 +5,5 @@ test('ary is a Function', () => {
});
const firstTwoMax = ary(Math.max, 2);
test('Discards arguments with index >=n', () => {
expect([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x))).toEqual([6, 8, 10]);
expect([[2, 6, 'a'], [6, 4, 8], [10]].map(x => firstTwoMax(...x))).toEqual([6, 6, 10]);
});