I have an array of arrays of Doubles. For example:
let mceGain = [[3,4,5],[7,4,3],[12,10,7]] // Written as integers for simplicity here
I would now like to average the elements in the different arrays with corresponding indexes. So I would have an output looking somewhat like this:
//firstAvg: (3+7+12)/3 = 7.33
//secondAvg: (4+4+10)/3 = 6
//thirdAvg: (5+3+7)/3 = 5
Then finally I would like to store these averages in a simpler array:
//mceGain: [7.33,6,5]
I have tried to do this with a double for-loop with a switch-statement inside, but this seems to be unnecessarily complicated. I assume the same result could be achieved using a combination of reduce(), map() and filter(), but I cannot seem to wrap my head around it.