What I have works, but I have a suspicion that there is a lodash method that can do this without the _.map().
const _ = require('lodash')
const ids = [1, 2]
const objects = [
{
id: 1,
foo: 'bar'
}, {
id: 2,
foo: 'baz'
}, {
id: 3,
foo: 'quux'
}
]
const result = _.map(ids, id => _.find(objects, { id }))
console.log(result)
// => [ { id: 1, foo: 'bar' }, { id: 2, foo: 'baz' } ]
Thanks!