How to $.extend 2 objects by adding numerical values together from keys with the same name?
- by muudless
I currently have 2 obj and using the jquery extend function, however it's overriding value from keys with the same name. How can I add the values together instead?
obj1 = {"orange":2,"apple":1, "grape":1}
obj2 = {"orange":5,"apple":1, "banana":1}
mergedObj = $.extend({}, obj1, obj2);
var printObj = typeof JSON != "undefined" ?…