I have two arrays :
let channelList = [
{
"channelId": 1,
"channelName": "SMS"
},
{
"channelId": 2,
"channelName": "EMAIL"
},
{
"channelId": 3,
"channelName": "ANDROID"
},
{
"channelId": 4,
"channelName": "IOS"
}
]
and
let promoList = [
{
"id": 124,
"channelType": "SMS"
},
{
"id": 125,
"channelType": "ANDROID"
},
{
"id": 126,
"channelType": "IOS"
}
]
I want a new array remainingChannels
which has
{
"channelId": 2,
"channelName": "EMAIL"
}
because it is not present in promoList
, but it is there in channelList
.
I am trying to get it using the filter operation like this:
for(let channel of this.promoDetailList) {
remainingChannels = this.channelList.filter(e => {
e.channelName == channel.channelType
});
}
How to do this?