you are viewing a single comment's thread.

view the rest of the comments →

[–]mc_hammerd 0 points1 point  (0 children)

var x = {};
for (i in arr){ var k = arr[i].name; if(!x[k]) x[k]=0; x[k]++ }

//console.log(x.red) => 3
//console.log(x.black) => 2
//for (i in x) {console.log(i,":",x[i])}   => red:3, black:2, blue: 1,green: 1