Simplify countBy

This commit is contained in:
Siarhei
2018-10-15 12:18:24 +04:00
parent fd927950a8
commit 782192943a
2 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ Use `Array.prototype.reduce()` to create an object, where the keys are produced
```js
const countBy = (arr, fn) =>
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => {
acc[val] = (acc[val] || 0) + 1;
return acc;
}, {});