JS, sorting and grouping an array of objects by condition

  arrays, javascript, object

I have an array of objects like this:

   {id: number, time: ms},
   {id: number, time: ms},
   {id: number, time: ms}

And I need to get such an object:

   time: [id, id, id],
   time: [id, id, id]

The original objects are compared by time, if there are several objects between which the difference in time is less than 60,000, then they need to be grouped into one object. The object key is the very first time value, and the value is an array of id.


Source: Ask Javascript Questions