I want to join two arrays by id but with different amount of elements, Does any suggestions?
Thanks
Array 1
soccer = [{id: 1, name: 'Munich'}, {id: 2, name: 'Dortmund'}]
Array 2
points = [{id: 2, value: 40}]
Result
result = [{id: 1, name: 'Munich'}, {id: 2, name: 'Dortmund', value: 40}]
My attempt was
teams.map((item,i)=>{
if(item.id === points[i].id){
return Object.assign({},item, points[i])
}
})