I would like to reduce an array of objects to a string array based on a boolean property.
My object array looks like that:
diet: [ { slug: "dairy-free", selected: true, }, { slug: "fish", selected: false, }, { slug: "meat", selected: false, }, { slug: "poultry", selected: true, }, { slug: "vegetarian", selected: true, }, ]
My ideal outcome would be a string array if the selected value is true.
["dairy-free", "poultry", "vegetarian"]