COMPARING TWO OBJECT VALUES

Question : Write a program to compare two object values, return true if they are equal else return false

function isEqual(obj1, obj2) {
let obj1Keys = Object.keys(obj1);
console.log(obj1Keys) //Prints: ['name']
let obj2Keys = Object.keys(obj2);
//comparing the length
if (obj1Keys.length !== obj2Keys.length) {
return false;
}
//looping on obj1Keys array using "for of" loop
for (let key of obj1Keys) {
if (obj1[key] !== obj2[key]) {
return false;
}
}
return true;
}
console.log(isEqual({ name: "John" }, { name: "John" }));
// Prints: true
console.log(isEqual({ name: "John" }, { name: "Bob" }));
// Prints: false