I have some questions:
Should I keep checking all elements in Objects or stop checking if I find one mismatch?
Should the items be in the same order in both objects?
I've got the same error in two variants of the solution:
const entries1 = Object.entries(obj1);
const entries2 = Object.entries(obj2);
if (entries1.length !== entries2.length) {
return false;
}
if (entries1.length === 0 && entries2.length === 0) {
return true;
}
for (const key in obj1) {
if (obj1[key] != obj2[key]) {
return false;
}
}
return true;
and the second variant:
const entries1 = Object.entries(obj1);
const entries2 = Object.entries(obj2);
if (entries1.length !== entries2.length) {
return false;
}
if (entries1.length === 0 && entries2.length === 0) {
return true;
}
for (let i = 0; i < entries1.length; i++) {
// Keys
if (entries1[i][0] !== entries2[i][0]) {
return false;
}
// Values
if (entries1[i][1] !== entries2[i][1]) {
return false;
}
}
return true;`
**the result failed on :
- The function isIdentical should return true if the objects are identical and false otherwise**