Skip to content Skip to sidebar Skip to footer

What's Wrong With My Array.filter Syntax?

this.firmCategories = this.firmCategories.filter(x => { x.id !== firmCatId; }); I can see that there is one element of the firmCategories array that has the matching ID by us

Solution 1:

You are missing a return statement.

this.firmCategories = this.firmCategories.filter(x => {
    return x.id !== firmCatId;
});

Or take an arrow function without a function body.

this.firmCategories = this.firmCategories.filter(x => x.id !== firmCatId);

Post a Comment for "What's Wrong With My Array.filter Syntax?"