Last active
August 27, 2019 07:57
-
-
Save cereme/cb4f817fc48c8e4c5636162724b9943a to your computer and use it in GitHub Desktop.
object_comparer.js
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
const object_comparer = (a, b, items) => { | |
return items.every(item => a[item] === b[item]); | |
} | |
const items = ['a', 'b']; | |
const q = { a: 1, b: 2 }; | |
const w = { a: 1, b: 2 }; | |
const e = { a: 1, b: 3 }; | |
console.log(object_comparer(q, w, items)); | |
// >> true | |
console.log(object_comparer(q, e, items)); | |
// >> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment