I would like to find values that are the same among javascript objects (perhaps later also add in a min , max statistic) I got stuck right at the start as my code returns some unexpected output (PS I am not looking for common properties, but for common properties that have the same values)
var obj1 = { "oranges": 5, "apples": 3, "peaches": 1 };
var obj2 = { "oranges": 4, "apples": 3, "peaches": 0 };
var obj3 = { "oranges": 5, "apples": 3, "peaches": 5 };
var obj_common = {};
for (var property in obj1) {
if (obj1[property] = obj2[property])
obj_common[property] = obj1[property];
}
console.log(obj_common);