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