Exercise-01 with Solution
Write a JavaScript program to compare two objects to determine if the first one contains equivalent property values to the second one
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Compare two objects to determine if the first one contains equivalent property values to the second one</title>
</head>
<body>
<script type="text/javascript" src="determine.js"></script>
</body>
</html>
const matches = (obj, source) =>
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
console.log(matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true })); // true
console.log(matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true })); // false
console.log(matches({ hair: 'long', beard: true }, { age: 26, hair: 'long', beard: true })); // false