How can I accomplish the following task? I want to check if the keys of object1 are present in object2. If a key is found, I need to compare its value with that of object2. If the values are different, I should replace the value in object2 with the one from object1.
Object1:
object1 = {
firstName: "Bob",
lastName: "Smith",
dob: "May 25, 1977"
}
Object2:
object2 = {
firstName: "Bobby",
lastName: "Jones",
dob: "May 25, 1977",
created: "May 24, 1977",
userLevel: "jedi"
}
Desired output for Object2:
object2 = {
firstName: "Bob",
lastName: "Smith",
dob: "May 25, 1977",
created: "May 24, 1977",
userLevel: "jedi"
}