Say I have an array like this:
["white", "red", "blue", "red", "white", "green", "red", "blue", "white", "orange"]
I want to go through an array and create a new array containing each individual color, and the number of times it appears in the original array.
So, in the new array it will be indicated that βwhiteβ appeared 3 times, βblueβ appeared 2 times and so on ...
How should I do it?
source
share