solved Task 2

This commit is contained in:
schrom01 2022-10-06 10:14:38 +02:00
parent b5aca0b708
commit d0e69401e0
1 changed files with 28 additions and 0 deletions

28
equal.js Normal file
View File

@ -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 }