i have 2 arrays of objects with the same structure , each one of them came from database query, how i can map the cross section into a new array by comparing the ID value.
tempArray=[{city:london,subject:"testdata", id:7777}, {city:london,subject:"testdata", id:5555}]
tempArray1=[{city:london,subject:"testdata", id:8888}, {city:london,subject:"testdata", id:5555}]
im trying to get the result:
newArray=[{city:london,subject:"testdata", id:5555}]
this is my try but i failed miserably
let newArray=tempArray.map((x)=>{
if (x.id== tempArray1.forEach((doc)=>{
console.log(doc.id);
return doc.id})) {return x
}
})