From d0e69401e073670764cf38c61a6dfb87a2e76b8f Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 6 Oct 2022 10:14:38 +0200 Subject: [PATCH] solved Task 2 --- equal.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 equal.js diff --git a/equal.js b/equal.js new file mode 100644 index 0000000..b8feafc --- /dev/null +++ b/equal.js @@ -0,0 +1,28 @@ +const { type } = require("os"); + +const equal = function(obj1, obj2) { + + if(obj1 === obj2){ + return true; + } else if(typeof(obj1) !== 'object' || typeof(obj2) !== 'object') { + return false + } + else { + let Isequal = true; + for (const [key, value] of Object.entries(obj1)) { + if(value !== obj2[key]) { + console.log(key, value, obj2[key]) + return false + } + } + for (const [key, value] of Object.entries(obj2)) { + if(value !== obj1[key]) { + return false + } + } + } + return true +} + + +module.exports = { equal } \ No newline at end of file