Category
The number of elements in iterable
. If predicate
was provided, the number of elements in iterable
that satisfy predicate
.
count([1, 2, 3]); // 3
count([1, 2, 3], number => number % 2 === 1); // 2
frequencyTable to count the occurrences of all elements in an iterable
Iterable
Count the number of elements in an iterable You may optionally provide a predicate function to filter which elements are counted.
Time complexity: O(n)
Space complexity: O(1)