I have an Object that looks like this:
var dataSource = [{
date: new Date(1994, 2, 2),
name: "a",
l: 24.00,
h: 25.00,
o: 25.00,
c: 24.875
}, {
date: new Date(1994, 2, 2),
name: "a",
l: 23.625,
h: 25.125,
o: 24.00,
c: 24.875
}, {
date: new Date(1994, 2, 3),
name: "a",
l: 26.25,
h: 28.25,
o: 26.75,
c: 27.00
}, {
date: new Date(1994, 2, 4),
name: "c",
l: 26.50,
h: 27.875,
o: 26.875,
c: 27.25
}, {
and so on... I want to combine entries by their date, meaning if two datapoints have the same date and name, I want to add them together so the output would be:
var dataSource = [{
date: new Date(1994, 2, 2),
name: "a",
l: 47.625,
h: 50.125,
o: 49.00,
c: 49.75
}, {
date: new Date(1994, 2, 3),
name: "a",
l: 26.25,
h: 28.25,
o: 26.75,
c: 27.00
}, {
date: new Date(1994, 2, 4),
name: "c",
l: 26.50,
h: 27.875,
o: 26.875,
c: 27.25
}, {
Right now the best way I can think of doing this would be a for loop that runs until the size of the object doesnt change any more. Is there a better way of doing this, possibly a jquery function similar to grep that could do this?