How would one take a javascript array of objects such as:
my objArr = [ {key:Mon Sep 23 2013 00:00:00 GMT-0400, val:42}, {key:Mon Sep 24 2013 00:00:00 GMT-04
var targetObj = {}; for (var i = 0; i < objArr.length; i++) { if (!targetObj.hasOwnProperty(objArr[i].key)) { targetObj[objArr[i].key] = 0; } targetObj[objArr[i].key] += objArr[i].val; }
http://jsfiddle.net/HUMxp/