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 potential method in typescript to achieve the desired result using the filter function? When the 'tags' field is not an array, it works fine. However, when it's within an array, the code does not produce the expected output.
I have attempted a solution but encountered failures:
data.filter(o => Object.keys(filterCondition).every(k => filterCondition[k].some(f => o[k] === f)));