I am looking for a solution to add additional keys to an object.
array = [{A: 5, B:10, C: 20},{A: 3, B: 2, C: 5}];
In the next step i will calculate a new_value:
array.forEach((element) => {
let new_value = ((element.A + element.B) / element.C;
Now, i have to add the result to each object in the above mentioned array:
array = array.map(element => new_value);
The outcome should be:
array = [{A: 5, B:10, C: 20, new_value: 0.75},{A: 3, B: 2, C: 5, new_value: 1.2}];
Unfortunately that´s not the case! How can I add the calculated value to the object?
2
Answers
From my above comments …
Simple enough
Code.gs
Execution log