I am trying to eliminate the duplicate elements inside a json object that is in an array but I can not do it, try with filter and with map but it seems that I can not access the json object, that is, I refer to it, here I show a example of the arrangement:
const q = [
{ zone: { _id: 'zone1', name: 'zone1' }, _id2: '143', name: 'ZONA1ALCALA' },
{ zone: { _id: 'zone1', name: 'zone1' }, _id2: '144', name: 'ZONA1OTRO' },
{ zone: { _id: 'zone2', name: 'zone2' }, _id2: '145', name: 'ZONA2OTRO MAS' },
{ _id: '146', name: 'ALBACETE' }
];
And what I would like is to be able to delete the zone1 dentor repeated element from the zone object that is in the array, for example I should return something like this:
const result = [
{ zone: { _id: 'zone1', name: 'zone1' }, _id2: '144', name: 'ZONA1OTRO' },
{ zone: { _id: 'zone2', name: 'zone2' }, _id2: '145', name: 'ZONA2OTRO MAS' },
{ _id: '146', name: 'ALBACETE' }
];
I would appreciate any help, I am trying in many ways all day and I still can not do it.