const arr = [
{
ticker: 'SPY',
strategy: 'OLD',
broker: 'OOH'
},
{
ticker: 'SPY',
strategy: 'LOG',
broker: 'FOR'
},
{
ticker: 'HG',
strategy: 'KIP',
broker: 'LOOP'
}
]
const arr2 = ['OLD', 'LOG']
const result = arr.filter(n => arr2.includes(n.strategy));
const result = arr2.flatMap(function(n) {
return this[n] ?? [];
}, arr.reduce((acc, n) => ((acc[n.strategy] ??= []).push(n), acc), {}));
const result = arr.filter(((values, n) => values.has(n.strategy)).bind(null, new Set(arr2)));
const result = [];
for (const n of arr) {
for (const m of arr2) {
if (m === n.strategy) {
result.push(n);
break;
}
}
}