Skip to content

Instantly share code, notes, and snippets.

@jhs
Forked from boxxxie/gist:1406402
Created November 30, 2011 02:50
Show Gist options
  • Save jhs/1407764 to your computer and use it in GitHub Desktop.
Save jhs/1407764 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