obj1 represents the original object while obj2 symbolizes the modified object. The goal is to extract the key-value pairs and types for all changed objects within the obje2 array of objects.
Therefore, I am looking for a solution where if the values for "name" or "id" are different in obj2, then return the object along with its type.
changedObj = [
{
type: "mobile",
name: "Temple Runs",
id: 2259
},
{
type: "pc",
name: "Pubgs",
id: 222
}
]
obj1 = [
{
type: "mobile",
games: [
{
name: "Temple Run",
id: 2259,
},
{
name: "Subway Surfer",
id: 2271,
},
{
name: "Pubg",
id: 2272,
},
],
},
{
type: "pc",
games: [
{
name: "Pubg",
id: 222,
},
{
name: "Fortnite",
id: 2274,
},
{
name: "Nfs",
id: 2272,
},
],
},
];
obj2 = [
{
type: "mobile",
games: [
{
name: "Temple Runs",
id: 2259,
},
{
name: "Subway Surfer",
id: 2271,
},
{
name: "Pubg",
id: 2272,
},
],
},
{
type: "pc",
games: [
{
name: "Pubgs",
id: 222,
},
{
name: "Fortnite",
id: 2274,
},
{
name: "Nfs",
id: 2272,
},
],
},
];
How can one accomplish such a task?