ran npm run tdd
This commit is contained in:
5
test/countBy/countBy.js
Normal file
5
test/countBy/countBy.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = countBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
||||
acc[val] = (acc[val] || 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
Reference in New Issue
Block a user