var binary = [1,0,0,1,1,1,0,0,1,0];
I have a function which produces a random array of bits. I would like to combine matching elements and return an array stating how many elements were repeated. The above giving the output = [1,2,3,2,1,1].
Are there any features in JavaScript which would allow me to do this? I have tried searching but not really sure how to describe what I want. Thanks.