data:[
{
id:1,
tags:['TagA','TagB','TagC']
},
{
id:2,
tags:['TagB','TagD']
},
{
id:3,
tags:['tagE','tagC']
}
]
filterCondition:{tags:['TagA','TagB']}
Expected Output: [
{
id:1,
tags:['TagA','TagB','TagC']
},
{
id:2,
tags:['TagB','TagD']
}
]
Is there a possible way to achieve this in typescript using filter method? It is possible when tags field is not an array but when it is in array the code breaks.
I tried but it fails:
data.filter(o => Object.keys(filterCondition).every(k => filterCondition[k].some(f => o[k] === f)));