I would like to return a unique array where the room object is the same.
var input = [
{
position:{
room: {
name: 'WC',
number: '001'
}
}
},
{
position:{
room: {
name: 'WC',
number: '001'
}
}
},
{
position:{
room: {
name: 'RWC',
number: '007'
}
}
}
];
So this list would be:
var input = [
{
position:{
room: {
name: 'WC',
number: '001'
}
}
},
{
position:{
room: {
name: 'RWC',
number: '007'
}
}
}
];
I tried this:
var distinctRooms = _.uniq(input, function(input){
return input.position.room
});
But it returns the entire list. Have not seen any example where you compare objects. Is this possible to do somehow with the _uniq?