[Junior Dev !!] [Javascript] Hi !
How can I group timestamps into daily intervals with a maximum of 3 objects in each group?
I've seen examples of grouping by timestamp, but how do we both order and limit the array size at the same time?
I have:
const restuls= [
{date: "2022-10-14T21:14:41.000Z", id: "1"},
{date: "2022-10-14T21:15:48.000Z", id: "2"},
{date: "2022-09-20T18:16:01.000Z", id: "3"},
{date: "2022-09-20T18:16:48.000Z", id: "4"},
{date: "2022-09-20T21:14:52.000Z", id: "5"},
{date: "2022-09-20T21:14:15.000Z", id: "6"},
{date: "2022-09-20T21:14:03.000Z", id: "7"},
{date: "2022-09-18T10:09:33.000Z", id: "8"},
{date: "2022-09-18T10:08:12.000Z", id: "9"},
{date: "2022-09-18T10:07:50.000Z", id: "10"}
]
Expected output:
[
[
{date: "2022-10-14T21:14:41.000Z", id: "1"},
{date: "2022-10-14T21:15:48.000Z", id: "2"}
],
[
{date: "2022-09-20T18:16:01.000Z", id: "3"},
{date: "2022-09-20T18:16:48.000Z", id: "4"},
{date: "2022-09-20T21:14:52.000Z", id: "5"}
],
[
{date: "2022-09-20T21:14:15.000Z", id: "6"},
{date: "2022-09-20T21:14:03.000Z", id: "7"}
],
[
{date: "2022-09-18T10:09:33.000Z", id: "8"},
{date: "2022-09-18T10:08:12.000Z", id: "9"},
{date: "2022-09-18T10:07:50.000Z", id: "10"}
]
]
Thanks