Counts the occurrences of each value in an array.
const a = [1, 2, 3, 4, 5, 6, 7, 8, 9];const isEven = (x: number) => x % 2 === 0;const b = countBy(isEven)(a);console.log(b); // { 'false': 5, 'true': 4 } Copy
const a = [1, 2, 3, 4, 5, 6, 7, 8, 9];const isEven = (x: number) => x % 2 === 0;const b = countBy(isEven)(a);console.log(b); // { 'false': 5, 'true': 4 }
Counts the occurrences of each value in an array.
Example