repeat name count js for.each 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; });