Q: How to comparing different values from two Object then pushing it into array type variable So here i have two object data:
{
    "obj1": {
        "product": "Book",
        "category": "sci-fi",
        "title": "interstellar",
    },
    "obj2": {
        "product": "Book",
        "category": "horror",
        "title": "evil dead",                    
    },
   "differences": []
}

From that data, i need to comparing each value from obj1 and obj2 variables find keys that have difference values from these two objects then pushing it into differences variable.
Expected Result:
{
    "obj1": {
        "product": "Book",
        "category": "sci-fi",
        "title": "interstellar",
    },
    "obj2": {
        "product": "Book",
        "category": "horror",
        "title": "evil dead",                    
    },
   "differences": [
        "category",
        "title"
   ]
}

Does anyone have recommendation to solving it?

A: You can simply make 2 loop, one for each object and then compare by key :
let data = {
  "obj1": {
    "product": "Book",
    "category": "sci-fi",
    "title": "interstellar",
  },
  "obj2": {
    "product": "Book",
    "category": "horror",
    "title": "evil dead",
  },
  "differences": []
};

for (let key1 in data.obj1) {
  for (let key2 in data.obj2) {
    if (key1 === key2 && data.obj1[key1] !== data.obj2[key2]) {
      data.differences.push(key1);
    }
  }
}
console.log(data);

