I'm having trouble with my TypeScript filter function.
Here is an array of objects:
[
{
"id": 12345,
"title": "Some title",
"complexity": [
{
"slug": "1", // This is my search term
"name": "easy"
}, {
"slug": "2", // This is my search term
"name": "middle"
},
{...}
Additionally, I have an array of strings containing the allowed complexities:
public allowedComplexityArray:Array<string> = ["1"];
My Objective: I want to display only the objects with the complexity "1".
However, my function is not working and I'm unsure why:
allowedMeals = meals.filter(meal => {
return meal.complexity.every(complexityObj => that.allowedComplexityArray.indexOf(complexityObj.slug) > -1)
});