我正在合并两个数组,它工作得很好。但我在日历上显示的数据,我需要一个数组作为一个单一的行使用。
我的数据:
[
{
"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;
}, []);
目前的结果
[
{
"Subject": "Service 1",
"StartTime": "2023-05-11",
"IsAllDay": true,
"CategoryColor": "#1aaa55",
"Description": "Address: AddressLine1Address"
}
]
想要的结果在宠物数组中可以进入主题行。可能有一个,也可能有很多。
[
{
"Subject": "Service 1 - Hound, Roger",
"StartTime": "2023-05-11",
"IsAllDay": true,
"CategoryColor": "#1aaa55",
"Description": "Address: AddressLine1Address"
}
]
我尝试了Map里面,但创建了一个新的行
3条答案
按热度按时间scyqe7ek1#
您可以尝试:
8ulbf1ek2#
基本上与前面的答案相同,使用map和join作为名称。
yyhrrdl83#
ChatGPT帮我修好了-