How to filter two arrays?
I have two arrays where allBrands are all brands and userBrands are brands that the user has already selected, I'm trying to filter allBrands in such a way that it doesn't show the brands already selected by the user
const allBrands = [
{ id: 0, title: "Apple" },
{ id: 1, title: "bmw" },
{ id: 2, title: "mercedes" },
{ id: 3, title: "samsung" }
];
const userBrands = [
{ id: 0, title: "Apple" },
{ id: 1, title: "mercedes" }
];
const filtered = allBrands.filter(({ title }) => {
return userBrands.map((item) => item.title !== title);
}); // need bmw, samsung