Update countBy.md

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-07-31 22:47:10 +03:00
committed by GitHub
parent 885b0c2af6
commit 199c60a0e5

View File

@ -19,5 +19,5 @@ const countBy = (arr, fn) =>
```js ```js
countBy([6.1, 4.2, 6.3], Math.floor); // {4: 1, 6: 2} countBy([6.1, 4.2, 6.3], Math.floor); // {4: 1, 6: 2}
countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1} countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1}
countBy([{ count: 5 }, { count: 10 }, { count: 5 }], item => item.count) // {5: 2, 10: 1} countBy([{ count: 5 }, { count: 10 }, { count: 5 }], x => x.count) // {5: 2, 10: 1}
``` ```