Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created November 29, 2011 20:40
Show Gist options
  • Save boxxxie/1406402 to your computer and use it in GitHub Desktop.
Save boxxxie/1406402 to your computer and use it in GitHub Desktop.
reduce:function(key, values, rereduce) {
function addPropertiesTogether(addTo,addFrom){
for (var prop in addFrom) {
(addTo[prop] !== undefined) ? addTo[prop] += Number(addFrom[prop]): addTo[prop] = Number(addFrom[prop]);
}
return addTo;
};
return values.reduce(addPropertiesTogether,{});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment