I have 3 objects of the same type with different values of their property. I would like to add them together as follow :
For example
objA = {
data: {
SH: { propertyA: 0, propertyB: 3, propertyC: 0},
....
}
}
objB = {
data: {
SH: { propertyA: 0, propertyB: 0, propertyC: 1},
....
}
}
objC = {
data: {
SH: { propertyA: 4, propertyB: 0, propertyC: 0},
....
}
}
And what I want a result like
objC = {
data: {
SH: { propertyA: 4, propertyB: 3, propertyC: 1},
...
}
}
is it possible to add them?
And if not, do you suggest any efficient way of coding for this instead of having three different types for each of them?
EDIT: By addition, I mean numerical addition of property values from the three objects. Though the objects also have some properties which could be string, I am only interested in number values.
In the end it is a lot of looping. How you do the looping can be done a bunch of ways. Easiest way os to look over the objects themselves and add things when they do not exist.