I have an array of objects that's created dynamically (in React, although I don't think it matters), and I'm attempting to use addition on values that have the same name.
for example:
[{ n1:"1", n2:"2", n3:"3"},
{ n1:"4", n2:"6", n3:"4"},
{ n1:"3", n2:"1", n3:"2"}]
the result of which would then be:
[{ n1:"8", n2:"9", n3:"9"}]
Spread Syntax and the .assign method seem like they'd accomplish this, but both examples have predefined arrays, not dynamically created ones.
If it would be easier to parse the data so each name could occupy a new array, that'd be fine too. ie [n1:"8"],[n2:"9"],[n3:"9"]