У меня есть ниже массив JSON.Я хочу установить расписания для dayOfWeek
, которых нет внутри schedules
других rooms
const data = {
rooms: [
{
roomId: 1,
schedules: []
},
{
roomId: 2,
schedules: [
{ home1: "05:05", dayOfWeek: 1, away: "20:30" },
{ home1: "06:05", dayOfWeek: 5, away: "21:30" },
{ home1: "07:05", dayOfWeek: 7, away: "22:30" }
]
},
{
roomId: 3,
schedules: []
}
]
}
Мне нужно скопировать те же расписания и в другие комнаты.
ожидаемый результат
const finalArray = [
{ home1: "05:05", dayOfWeek: 1, away: "20:30", roomId: 1 }, //schedules from room2
{ home1: "06:05", dayOfWeek: 5, away: "21:30", roomId: 1 }, //schedules from room2
{ home1: "07:05", dayOfWeek: 7, away: "22:30", roomId: 1 }, //schedules from room2
{ home1: "05:05", dayOfWeek: 1, away: "20:30", roomId: 3 }, //schedules from room2
{ home1: "06:05", dayOfWeek: 5, away: "21:30", roomId: 3 }, //schedules from room2
{ home1: "07:05", dayOfWeek: 7, away: "22:30", roomId: 3 }, //schedules from room2
]
Я пытался, но не смог заставить его работать !!!Пожалуйста, помогите !!!