I have the following object:
obj = [
{ 1: 20, 2: 26, 3: 14},
{ 1: 12, 2: 25, 3: 15},
{ 1: 14, 2: 13, 3: 19},
{ 1: 16, 2: 32, 3: 21}
]
and I want to multiply by 2 each of the positions and then add them to each position, let me explain: I multiply each value by 2 and this is the partial result:
obj = [
{ 1: 40, 2: 52, 3: 28},
{ 1: 24, 2: 50, 3: 30},
{ 1: 28, 2: 26, 3: 38},
{ 1: 32, 2: 72, 3: 42}
]
then I must add each key and add the total by adding a new array at the end inside the initial object, and this should be the final result:
obj = [
{ 1: 20, 2: 26, 3: 14},
{ 1: 12, 2: 25, 3: 15},
{ 1: 14, 2: 13, 3: 19},
{ 1: 16, 2: 32, 3: 21},
{ 1: 104, 2: 200, 3: 138}
]
32 * 2is not72,40 + 24 + 28 + 32is not104-- it's124