Currently, I got an array like that:
var uniqueCount = Array();
After a few steps, my array looks like that:
uniqueCount = [a,b,c,d,d,e,a,b,c,f,g,h,h,h,e,a];
How can I count how many a,b,c are there in the array? I want to have a result like:
a = 3
b = 1
c = 2
d = 2
etc.
Something like this:
Use a simple for loop instead of forEach if you don't want this to break in older browsers.
I think this is the simplest way how to count occurrences with same value in array.
You can solve it without using any for/while loops ou forEach.
Hope it helps you!
A combination of good answers:
Hope it's helpful.
By using array.map we can reduce the loop, see this on jsfiddle
To Test: