I'm having a bit of a problem trying to get the exact output.
const data = [{
name: 'Alex Young',
country: 'SE',
nID: 424
address: 'some address 12'
},{
name: 'Martha Lewis',
country: 'PT',
nID: 312,
address: 'an address 49'
},{
name: 'Sophie Jones',
country: 'NL',
nID: 36,
address: 'other address 3129'
}];
const filter = '12';
const keysToEvaluate = ['name', 'country', 'address'];
For the given data, I would like to evaluate only the given keysToEvaluate and output all objects where the values contains the filter.
expected output:
[{
name: 'Alex Young',
country: 'SE',
nID: 424
address: 'some address 12'
},{
name: 'Sophie Jones',
country: 'NL',
nID: 36,
address: 'other address 3129'
}]
TIA