How to remove duplicates objects in array and the original value based on 2 properties
This what i do but this return the original
const rooms = [
{
room_rate_type_id: 202,
price: 200
},
{
room_rate_type_id: 202,
price: 200
},
{
room_rate_type_id: 202,
price: 189
},
{
room_rate_type_id: 190,
price: 200
}
];
let result = rooms.filter((e, i) => {
return rooms.findIndex((x) => {
return x.room_rate_type_id == e.room_rate_type_id && x.price == e.price;}) == i;
});
console.log(result);
i want the result to be only
{
room_rate_type_id: 202,
price: 189
},
{
room_rate_type_id: 190,
price: 200
}