I have an array of objects that looks like this
[
{ id: 1, state: 'PURCHASED' },
{ id: 2, state: 'PURCHASED' },
{ id: 3, state: 'SOLD' },
{ id: 1, state: 'SOLD' },
{ id: 4, state: 'PURCHASED' },
{ id: 6, state: 'SOLD' },
{ id: 9, state: 'PURCHASED' }
]
I would like to filter this array such that I get the items which were PURCHASED but never SOLD. The out would look something like this
[
{ id: 2, state: 'PURCHASED' },
{ id: 3, state: 'SOLD' },
{ id: 4, state: 'PURCHASED' },
{ id: 6, state: 'SOLD' },
{ id: 9, state: 'PURCHASED' }
]