I have an array of objects. Note that "created" sometimes has the same value more than once. Also note that "status" is sometimes "0":
var array = [
{"created":"Jan 1","status":1},
{"created":"Jan 1","status":1},
{"created":"Jan 2","status":1},
{"created":"Jan 3","status":0},
{"created":"Jan 4","status":1},
{"created":"Jan 4","status":1}
];
I want a new a new array of objects like this:
var newArrayA = [
{"Jan 1":2},
{"Jan 2":1},
{"Jan 3":0},
{"Jan 4":2}
];
OR a multidimensional array like this (I'm not sure which is better for D3.js):
var newArrayB = [
["Jan 1",2],
["Jan 2",1],
["Jan 3",0],
["Jan 4",2]
];
So, when "status" is "1", it counts the number of "created" that are the same. And when status is "0", that is also included.
How do I do this? Here's what I have so far JSFIDDLE. Is this how to approach it? Or am I missing some simple solution? Thanks!