My task involves working with two arrays of objects, each containing a unique property id that corresponds to a filterID retrieved from a dynamoDb database. The goal is to extract the objects that have different values associated with the same id.
const firstArray = [
{
1234: "food"
},
{
5678: "animal"
},
{
4444: "car"
}
]
const secondArray = [
{
1234: "food"
},
{
5678: "bread"
},
{
4444: "car"
}
]
const findDifferentObjects = () => firstArray.filter(object1 => {
return !secondArray.some(object2 => {
return object1 === object2
})
})
console.log(findDifferentObjects())
Basically, what I'm aiming for is to obtain:
const different = [
{
5678: "animal"
},
]
I have experimented with different approaches, similar to the example provided, but haven't been successful yet.