how to count same element in array javascript code example
Example: counting duplicate values javascript
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });