Skip to content

Instantly share code, notes, and snippets.

@fatihtoprak
Created January 21, 2021 22:26
Show Gist options
  • Select an option

  • Save fatihtoprak/4e4fd7b3c3af7720b79a5e469f476db2 to your computer and use it in GitHub Desktop.

Select an option

Save fatihtoprak/4e4fd7b3c3af7720b79a5e469f476db2 to your computer and use it in GitHub Desktop.
const filters = ['a', 'b'];
const results = [
{
name: 'Result 1',
category: ['a']
},
{
name: 'Result 2',
category: ['a', 'b']
},
{
name: 'Result 3',
category: ['c', 'a', 'b', 'd']
}
];
const filteredResults = results.filter(item =>
filters.every(val => item.category.indexOf(val) > -1)
);
console.log(filteredResults);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment