Skip to content

Instantly share code, notes, and snippets.

@huyen-nguyen
Created June 17, 2019 21:57
Show Gist options
  • Save huyen-nguyen/e3bae4b5f3f4d0e1d0648b37648a27cd to your computer and use it in GitHub Desktop.
Save huyen-nguyen/e3bae4b5f3f4d0e1d0648b37648a27cd to your computer and use it in GitHub Desktop.
input: a stack
output: sum of all y0, y1, including data ({})
for (let i = 0; i < stacks[0].length; i++){
let point = [];
point[0] = stacks.reduce(
(accumulator, currentValue) => accumulator + currentValue[i][0],0);
point[1] = stacks.reduce(
(accumulator, currentValue) => accumulator + currentValue[i][1],0);
point.data = stacks[0][i].data;
total.push(point);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment