I have an array from the api response and its objects.I need to find the value which has maximum total and I have display it I'm unable to solve it , when there are two max values of the total.Is there any solution?
myArray[
{time: "2018-12-02", total: 25, percentage: 20, averageTime: 20},
{time: "2018-13-02", total: 25, percentage: 20, averageTime: 20},
{time: "2018-14-02", total: 35, percentage: 25, averageTime: 25},
{time: "2018-16-02", total: 65, percentage: 60, averageTime: 20},
{time: "2018-17-02", total: 40, percentage: 20, averageTime: 20},
{time: "2018-18-02", total: 65, percentage: 20, averageTime: 20},
{time: "2018-18-02", total: 35, percentage: 23, averageTime: 20}
];
I tried reduce function like this:
var data =[];
data.reduce((max, p) => p.total > max ? p.total : max, data[0].total);