countBy
CountBy is a utility function found in libraries such as lodash. It creates an object composed of keys generated by running each element of a collection through an iteratee, with the value for each key being the number of elements that produced that key.
The typical signature accepts a collection (an array, an array-like object, or an object) and an iteratee.
The return value is an object whose enumerable properties represent the computed keys and whose values are
Example: countBy([6.1, 4.2, 6.3], Math.floor) yields { '4': 1, '6': 2 }. Another example: countBy(['apple', 'banana', 'apricot'], x
Compared with groupBy, which groups elements into arrays by key, countBy returns only the frequencies. It is