Each product in the array contains a unique structure that includes an ID, name, and materials list. The materials list consists of various materials with their own IDs and names.
{
id: 1,
name: "product 1",
materials: [
{
id: 1,
name: "material 1"
},
{
id: 2,
name: "material 2"
},
{
id: 3,
name: "material 3"
}
]
}
Every product can have a different number of materials in its materials list.
In addition, there is a separate array containing material IDs such as [1, 4, 7, 2, 5]
.
The task at hand is to filter the array of products so that only products with materials whose IDs match those in the array of material IDs remain.