I have an array with same cohort_id, stats_type and service_date_end
[
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-04 11:20:20'
  },
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-04 09:20:20'
  },
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-04 09:19:20'
  },
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-03 09:19:20'
  },
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2021-01-01',
    calculation_time: '2021-01-01 09:19:20'
  },
  {
    cohort_id: '1',
    stats_type: 'comprehensive',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-01 09:19:20'
  },
  {
    cohort_id: '1',
    stats_type: 'diagnostic',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-03 09:19:20'
  },
  {
    cohort_id: '1',
    stats_type: 'diagnostic',
    service_date_end: '2020-11-30',
    calculation_time: '2021-01-02 09:19:20'
  }
]
for every identical stats type and service date end i would like to have only those records with the most current calculation time and eliminate other data from the array How do I accomplish that in JavaScript?
 
    