While browsing Stack Overflow, I stumbled upon a question that has yet to be answered: How can I count the occurrences of elements in a specific array using JavaScript?.
let array = [6, 1, 5, 1, 1, 8, 2, 4, 6, 0] // Elements in array
getOccurrence(array) /* returns
[
{occurrence: x, item: array[y]},
{occurrence: ..., item: ...},
{...},
]
where 'x' is the frequency of an item in the array.
*/
If there are any algorithms that can achieve this, please advise.