Dev Helpers
← Back

Count simultaneous start events

Count simultaneous start events using JavaScript.

Open this example in the interactive library

Source code

const times = [9, 10, 9, 14, 10, 9];
console.log(
  [...Map.groupBy(times, (t) => t)].map(([time, events]) => ({
    time,
    count: events.length,
  })),
);

Sample output

[
  { time: 9, count: 3 },
  { time: 10, count: 2 },
  { time: 14, count: 1 }
]