Here is a sample of the global.heights array:
[[190, 76, 209, 57, 114, 171, 76, 513, 209, 171, 76, 152, 76, 76, 190, 114, 95, 76, 76, 95, 57, 133, 114], [152, 76, 133, 38, 95, 133, 76, 342, 190, 114, 57, 152, 76, 57, 133, 76, 76, 76, 57, 76, 57, 76, 76], [], []]
What I need to do is make another array a part of the global array (simple, something like global.offset = new Array() works fine). It needs to look something like this:
[[190, 266, 475, ...], [...], [], []]
Basically each place is the value thus far. As in global.offset[2] is the first three added, and so forth throughout the array.
But if I try something like:
for(i = 0, e < global.heights.length; i < e; i++) {
for(j = 0, k < global.heights[1].length; j < k; j++) {
global.offset[i][j] = Number(global.offset[i][j - 1]) + Number(global.heights[i][j]);
}
}
If I do that I get an undefined error that global.offset is not an object (but it is already initialized and with four arrays inside it.
I am new to JS.
Thanks