Created
May 29, 2020 00:04
-
-
Save harrisonmalone/5c4c04eb7b4899c407c10c11df405e16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// harrison will show you how to run the tests and also what lodash is | |
// https://www.npmjs.com/browse/depended | |
/* | |
Is Match | |
Tells you if the keys and values in properties are contained in object. | |
Example: | |
var stooge = {name: 'moe', age: 32}; | |
isMatch(stooge, {age: 32}); | |
=> true | |
*/ | |
const isMatch = (objOne, objTwo) => { | |
// Your code here! | |
// how do we loop through an object | |
// for in | |
// hasOwnProperty | |
for (let key in objOne) { | |
if (objTwo.hasOwnProperty(key)) { | |
if (objOne[key] === objTwo[key]) { | |
return true | |
} | |
} | |
} | |
return false | |
} | |
const stooge = {name: 'moe', age: 32}; | |
const keys = Object.keys(stooge) | |
const values = Object.values(stooge) | |
keys.forEach((key, index) => { | |
console.log(key) | |
console.log(values[index]) | |
}) | |
isMatch(stooge, {age: 32}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment