i have an array with objects inside which contain values "x" and "y", i'm trying to sum only "y" in a way that it acumulates it's value.
These are the objects i currently have
obj[0]: {x: "2020-09-30", y: 593}
obj[1]: {x: "2020-09-29", y: 100}
obj[2]: {x: "2020-09-25", y: 331}
obj[3]: {x: "2020-09-24", y: 901}
obj[4]: {x: "2020-09-21", y: 50}
These is the result im looking for
obj[0]: {x: "2020-09-30", y: 593}
obj[1]: {x: "2020-09-29", y: 693}
obj[2]: {x: "2020-09-25", y: 1024}
obj[3]: {x: "2020-09-24", y: 1925}
obj[4]: {x: "2020-09-21", y: 1975}
this is a snippet i came up with but doesn't work, does anyone have an idea how it could work?
for(var i=1; i<=obj.length; i++){
var j=i-1
obj[i.y] = obj[i.y] + obj[j.y]
}