0
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 using my debugger, however, I am left with a completely empty array after this executes.

I would expect to have every element except for the one that has the matching ID leftover. What's up?

333Matt
  • 1,124
  • 2
  • 19
  • 29

1 Answers1

5

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);
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
  • Formatted it like that in order to debug, but so you can't use a function body with the lambda. Never would've guessed, thank you! – 333Matt Mar 25 '20 at 19:50