Looking for a way to merge Javascript Object keys inside array, only on matching Ids. Should i use Map? or flatmap? I have
const districtList =[
{ id:'1234blah', companyId:'09871345', districtName:'abc1' },
{ id:'2341blah', companyId:'87134590', districtName:'abc2' },
{ id:'3412blah', companyId:'09134587', districtName:'abc3' },
]
and
const companyList =[
{id:'09871345', companyName:'CompanyOne', info:'some' },
{id:'87134590', companyName:'CompanyTwo', info:'stuff' },
{id:'09134587', companyName:'CompanyThree', info:'todo' },
]
But what i want is the data from the company array inside the district array, to get the missing company name, and other info.
const improvedDistrictList =[
{ id:'1234blah', companyId:'09871345', districtName:'abc1', companyName:'CompanyOne', info:'some' },
{ id:'2341blah', companyId:'87134590', districtName:'abc2', companyName:'CompanyTwo', info:'stuff' },
{ id:'3412blah', companyId:'09134587', districtName:'abc3', companyName:'CompanyThree', info:'todo' },
]