I have 3 objects in an array in which all of them have an equal number of data properties. The data is as follows:
const monthStats = [{
name: 'pending',
data: ['5', '1', '2', '3', '100', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '20', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
}, {
name: 'delivered',
data: ['10', '44', '12', '0', '250', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '180', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
}, {
name: 'failed',
data: ['15', '33', '30', '2', '150', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '50', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
}];
The data is representation of date values in a month(So they have equal length). What I want is to get the sum of values of alternate data of each dates and get the maximum value out of it.
Alternate here means for example: on pending 0th index has value 5, similarly on delivered is 10 and on failed is 15. Their total sum is 30. Here, the maximum value in the above example is 500 on the 4th index after summing them and that's what I want.
How can I achieve this?
monthStatslength will be 3?