I want to filter an array of objects with an array attribute based on another array:
[
{
id: 50,
name: 'test1',
countries: ['RO','GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}, {
id: 52,
name: 'test3',
countries: ['DE'],
}
]
I want to return an array of objects that can by filtered by an array of countries, meaning if I want to filter by 1, 2 countries.
1. countries: ['RO']
or
2. countries: ['RO', 'DE'],
The expected output would be:
1.
[
{
id: 50,
name: 'test1',
countries: ['RO', 'DE' ,'GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}
]
2.
[
{
id: 50,
name: 'test1',
countries: ['RO', 'DE' ,'GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}, {
id: 52,
name: 'test3',
countries: ['DE'],
}
]