I'm currently working with 2 objects that will always have the same amount of properties, but their values may vary.
In my attempt to check if the two objects hold the same values, I decided to use the .every
method. However, all results are returning false
, even though I am expecting them to be true.
How can I compare these 2 objects to determine if they are equal?
Below is a snippet of the code:
const priceOne = {
"price": 14.31,
"taxes": 2.00,
"total": 16.31
}
const priceTwo = {
"price": 14.31,
"taxes": 2.00,
"total": 16.31
}
const comparePrice = Object.keys(priceOne).every((item, index) => {
item === Object.keys(priceTwo)[index] ? true : false
})
console.log(comparePrice)