Sample code.
const cards = [
{
id: "1",
name: "J",
tag: [
{
"colour": "red"
},
{
"colour": "yello"
},
{
"colour": "blue"
},
{
"colour": "white"
},
],
size: [
{
"name": "small"
},
{
"name": "medium"
},
],
},
{
id: "2",
name: "S",
tag: [
{
"colour": "red"
},
{
"colour": "green"
},
{
"colour": "black"
},
],
size: [
{
"name": "small"
},
{
"name": "medium"
},
],
},
{
id: "3",
name: "K",
tag: [
{
"colour": "green"
},
{
"colour": "purple"
},
{
"colour": "brown"
},
{
"colour": "white"
},
],
size: [
{
"name": "large"
},
],
}
];
Test arrays
const sizeArray = ["medium", "small"];
const tagArray = ["red", "black"];
I want the filtered array of objects to only include the second object in this example. Filtering only those who match all criteria leaving me with a new array of objects.
I've tried with .filter, .some, .includes and no luck looking over many other answers to similar questions.
Thanks a lot.