diff --git a/src/deepEqual.js b/src/deepEqual.js index 860208b..4eaf4e2 100644 --- a/src/deepEqual.js +++ b/src/deepEqual.js @@ -20,7 +20,23 @@ * @return {boolean} */ function deepEqual(a, b) { - // write code here + if (Object.is(a, b)) { + return true; + } + + if (typeof a !== 'object' || typeof b !== 'object' + || a === null || b === null) { + return false; + } + + const keysA = Object.keys(a); + const keysB = Object.keys(b); + + if (keysA.length !== keysB.length) { + return false; + } + + return keysA.every(key => deepEqual(a[key], b[key])); } module.exports = deepEqual;