Here is the item1 data:
const item1 = [
{
"proposedWaterClosets": 2,
"proposedToilets": 3,
"noOfWaterClosets": 3,
"noOfToilets": 3
},
{
"proposedWaterClosets": 2,
"proposedToilets": 3,
"noOfWaterClosets": 3,
"noOfToilets": 2
}
]
Here is the item2 data:
const item2 = {
"proposedWaterClosets": 2,
"proposedToilets": 3,
"noOfWaterClosets": 3,
"noOfToilets": 3
}
I want the output to be like this which only return the difference value
expected output:
[{ "noOfToilets": 3 }]
Here I am having issue , I am getting which the value is same .. here is my approach using map and with the help of if condition, the thing is I am getting the output which is equal … Any suggestions would be appreciated
const result = item1.map((it) => {
if (it.noOfToilets !== item2.noOfToilets || it.noOfWaterClosets !== item2.noOfWaterClosets) {
return { oldToilets: it.noOfToilets, oldWaterC: it.noOfWaterClosets };
}
});
getting output: [{oldToilets::2,oldWaterC:3}]