I have a 2D array which is structured like so:
I would like to sum the values relative to their index ie. (-10000 + 100 + 100 + -100). Then store these in a separate array which would look something like:
[[500], [-10100], [9000], [18000], [18000]]
I would imagine I'd have to use map and reduce to achieve this, but I'm not having much luck.
Here's what I currently have:
for (var i=1; i<totals.length; i++) {
    for (var z=0; z<totals[i].length; z++) {
        console.log(totals[i][z] = totals[i-1][z] + totals[i][z]);
    }
}
However, that seems to output the following:
If someone could push me in the right direction, that would be awesome.



