I have an array of objects named profiles: [{id: 0, subcategories: ['A', 'B', 'C']}, {id: 1, subcategories: ['A']}]
I have an array named tags: ['B']
I want to filter profiles, only keeping profiles that have a value in tags. In this case, profile with id = 0 would be saved.
This is what I have tried so far and it doesn't seem to be working:
let filtered_profiles = profiles.filter((profile) =>
tags.includes(profile.subcategories)
);
let filtered_profiles = profiles.filter((profile) => profile.subcategories.some(sub => tags.includes(sub)));