How can I create a function that return true if all the properties in two objects are the same? I have come up with the following code which will return true if at least one of the properties are the same. However if one of the properties are different, it should return false. Bear in mind that I'm in the learning process of JavaScript...Thank you!
function BuildAddress(street, city, zipCode) {
this.street = street;
this.city = city;
this.zipCode = zipCode;
}
const address1 = new BuildAddress('a', 'b', 101);
const address2 = new BuildAddress('a', 'b', 101);
function areEqual(address1, address2) {
for (let key in address1)
for (let value in address2)
if (address1[key] === address2[value]) return true;
return false;
}