diff --git a/package.json b/package.json index 29cd1e0..47dff41 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "license": "GPL-3.0", "devDependencies": { "@mate-academy/eslint-config": "*", - "@mate-academy/scripts": "^0.3.5", + "@mate-academy/scripts": "^0.6.5", "eslint": "^5.16.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", diff --git a/src/deepEqual.js b/src/deepEqual.js index 860208b..27268a5 100644 --- a/src/deepEqual.js +++ b/src/deepEqual.js @@ -20,7 +20,26 @@ * @return {boolean} */ function deepEqual(a, b) { - // write code here + if (Object.is(a, b)) { + return true; + } + + if (typeof a !== 'object' || typeof b !== 'object') { + return false; + } + + if (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;