Skip to content
On this page

countBy

Count the number of elements that match a given condition.

Example

countBy([1, 2, 3, 4, 5], (x) => x % 2 === 0) // => 2

Playground

const { countBy } = require('rhodash')
countBy([1, 2, 3, 4, 5], (x) => x % 2 === 0) // => 2