I need to update (or create new array) the id value in obj1 based on the id value in obj2. What is the best way to do this? I've tried with map and reduce but I wasn't successful. Any help will be appreciated.
const obj1 = [ { id: 1, name: 'foo' }, { id: 2, name: 'bar' } ]
const obj2 = { A: { id: 1, externalId:'AAA' }, B: { id: 2, externalId:'BBB' } }
outputExpected: [ { id: 'AAA', name: 'foo' }, { id: 'BBB', name: 'bar' } ]