data = [{
id: "txv3vvBr8KYB",
name: "room 1"
},{
id: "txv3vvBr8KJB",
name: "room 2"
},{
id: "txv3vvBr8K",
name: "room 4"
},{
id: "txv3vvBr8LKP",
name: "room 3"
},{
id: "txv3vvBr8LDS",
name: "room 5"
}]
roomList = [
{
room: {
code: "r001",
id: "txv3vvBr8KYB",
name: "room 1",
status: "FULL"
}
},
{
room: {
code: "r002",
id: "txv3vvBr8KJB",
name: "room 2",
status: "FULL"
}
},
{
room: {
code: "r003",
id: "txv3vvBr8LKP",
name: "room 3",
status: "FULL"
}
}
]
What I'm trying to do here is to filter the data from the roomList and remove the item from data when they are the same ids.
the expected output should be like this:
data = [{
id: "txv3vvBr8K",
name: "room 4"
}{
id: "txv3vvBr8LDS",
name: "room 5"
}]
I tried to use a filter and map.
this.data.filter((x: any) => this.roomList.map((y: any) => y['room']['id] === x['id']);