mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Update countBy doc example to be more at a glance friendly. [closes #3771]
This commit is contained in:
10
countBy.js
10
countBy.js
@@ -17,8 +17,14 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
* @returns {Object} Returns the composed aggregate object.
|
||||
* @example
|
||||
*
|
||||
* countBy([6.1, 4.2, 6.3], Math.floor)
|
||||
* // => { '4': 1, '6': 2 }
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'betty', 'active': true },
|
||||
* { 'user': 'fred', 'active': false }
|
||||
* ]
|
||||
*
|
||||
* countBy(users, 'active');
|
||||
* // => { 'true': 2, 'false': 1 }
|
||||
*/
|
||||
function countBy(collection, iteratee) {
|
||||
return reduce(collection, (result, value, key) => {
|
||||
|
||||
Reference in New Issue
Block a user