I'm trying to retrieve all unique values from an array inside and object, inside an array
var items = [
{
colors:['white', 'black'],
fruits:['apple, banana']
},
{
colors:['yellow', 'black'],
fruits:['mango, blueberry'],
},
...
]
const property = 'colors'
const values = this.distinct(this.items.map(item => item[property].map(elem => elem))
I want the values to return an array with each value of colors so, like this:
['black','white','yellow']
But it's not working, and I don't understand why