I came across a JavaScript array that looks like this:
var array1 = [ [1, 2, 3], [7, 9, 2], [6, 8, 1] ]
What I'm aiming for is to get the following output:
var array2 = [ 14, 19, 6 ]
array1[0] = 1 + 7 + 6
array1[1] = 2 + 9 + 8
array1[2] = 3 + 2 + 1
Is there a way to sum each element of an array based on its index?