const a = [
{
"record_id": "2ff8212f-5ec9-4453-b1f3-91840a3fb152",
"status_date_activity": {
"On Rent": 1663841740869
}
},
{
"record_id": "c8c11f97-5eda-4f9b-a6a0-5a3f259c85b6",
"status_date_activity": {
"On Rent": 1663826452195
}
},
{
"record_id": "8c23aa44-4113-4feb-92b7-eb265f3e11e2",
"status_date_activity": {
"On Rent": 1663837445146,
"Draft": 1663808712701,
"Active": 1663808565409
}
},
{
"record_id": "fd88fbfc-a8d3-4a86-b245-0f8334b4f11f",
"status_date_activity": {
"On Rent": 1663841622113
}
},
{
"record_id": "e0ed3dcf-943c-48d1-b387-87e758e5ed9a",
"status_date_activity": {
"On Rent": 1663814717259,
"Unprepped": 1663841617839
}
},
{
"record_id": "cef4d093-0ced-4d0d-b9f6-90c2e2687bbe",
"status_date_activity": {
"On Rent": 1663892940412
}
}
]
Given the array above, my goal is to return an array of object that are group according to date(On Rent). But first I need to get the start of the month (for example this month is september, and also the current date of this month so for example Sept 25) so my final output should be like this
const final_result = [
{
Sept 1: [] // empty array because theres is no on rent on this day
},
{
Sept 2: []// empty array because theres is no on rent on this day
},
...and so on on,
{
Sept 22:[{
...the value above that on rent is belong to this date( no matter what time it is)
}]
},
...until it reaches to
Sept 25:[]// empty array because theres is no on rent on this day
]