I have an array
const newChecked = ["recreational", "charity"]
and an object
const allActivities = [
{activity: '...', type: 'social', },
{activity: '...', type: 'social', },
{activity: '...', type: 'charity', },
{activity: '...', type: 'recreational', },
]
And I want to get a new object, that does not contain type that are contains in newChecked. In other words, newActivitiesList
should contain data with type
of "social"
.
const newActivitiesList = allActivities.filter((item) =>
newChecked.map((i) => {
return item.type !== i;
})
);