I am merging two arrays which is working great. But i am showing the data on a calendar and i need an array to be used as a single line.
My Data:
[
{
"pets": [
{
"name": "Hound",
"id": "290dH8Z7nE3kKqMWcsj5"
},
{
"name": "Roger",
"id": "290dH8Z7nE3kKqMWcsj7"
}
],
"date": [
{
"date": "2023-05-11"
}
],
"typeofservice": "Service 1",
"datestart": "2023-05-11",
"outsideshift": false,
"organizationId": "vrpMguv6cwf7L9KLEknR",
"AddressLine1": "7j2UsMaCI1ehnHl5FbMf",
}
]
const partialDetails = a3.reduce((res, item) => {
res.push({ Subject: item.typeofservice , StartTime: item.datestart, IsAllDay: true, CategoryColor: "#1aaa55", Description: "Address: " + item.AddressLine1 })
return res;
}, []);
Results Currently
[
{
"Subject": "Service 1",
"StartTime": "2023-05-11",
"IsAllDay": true,
"CategoryColor": "#1aaa55",
"Description": "Address: AddressLine1Address"
}
]
Wanted result the array in pets to be able to go into the subject line. There could be 1 there could be many.
[
{
"Subject": "Service 1 - Hound, Roger",
"StartTime": "2023-05-11",
"IsAllDay": true,
"CategoryColor": "#1aaa55",
"Description": "Address: AddressLine1Address"
}
]
Ive tried map inside but that creates a new line
3
Answers
ChatGPT fixed it for me -
You can try:
basically the same as previous answer using map and join for the names.