From the following object
items = [{
title = 'title 1',
category = 'foo'
},
{
title = 'title 5',
category = 'bar'
},
{
title = 'title n',
category = 'bar'
},
]
which
- I receive dynamically at runtime
- can have any length
- where each category field can have one of up to
items.length
values
I want to get the set of all different values for the field category
.
In the example above, the result of
get_all_possible_categories(items)
would be
['foo','bar'].
How can I implement
get_all_possible_categories(items) ?