Having two distinctive arrays:
accomodation: [
{
id: 1,
name: "Senator Hotel Fnideq",
address: "Route de Ceuta, 93100 Fnidek, Morocco",
checkin: "September 1",
fullCheckinDate: "2021-09-01",
checkout: "September 3",
fullCheckoutDate: "2021-09-03",
nights: 2,
mealplan: "Breakfast,Lunch"
},
{
id: 2,
name: "Kabek Morocco Hotel",
address: "Omis Juy, 93100 Kabek, Morocco",
checkin: "September 3",
fullCheckinDate: "2021-09-03",
checkout: "September 5",
fullCheckoutDate: "2021-09-05",
nights: 2,
mealplan: "Breakfast,Lunch"
}
]
experiences: [
{
id: 1,
fullDate: "2021-09-01",
title: "Arrival",
itinerary: // []
},
{
id: 2,
fullDate: "2021-09-02",
title: "Sightseeing",
itinerary: // []
}
]
Looking to merge the common dates in accommodation and experiences into an object.
myTrips: [
{
accomodation: {
id: 1,
name: "Senator Hotel Fnideq",
address: "Route de Ceuta, 93100 Fnidek, Morocco",
checkin: "September 1",
fullCheckinDate: "2021-09-01",
checkout: "September 3",
fullCheckoutDate: "2021-09-03",
nights: 2,
mealplan: "Breakfast,Lunch"
},
experiences: {
id: 1,
fullDate: "2021-09-01",
title: "Arrival",
itinerary: // []
}
},
//... another object
]
Utilizing dayjs
for date operations. What steps should I take?