I need to filter an array using two criteria: one is straightforward (==1) and the other involves an array. In this example, I want to filter where level = 0 or name includes ['B','S'].
[
{id: 1, level: 0, name: 'A'},
{id: 2, level: 1, name: 'B'},
{id: 3, level: 1, name: 'S'},
{id: 4, level: 0, name: 'A'},
{id: 5, level: 0, name: 'S'},
{id: 6, level: 1, name: 'A'},
{id: 7, level: 0, name: 'B'}, ]
Therefore, the desired result would be:
[
{id: 1, level: 0, name: 'A'},
{id: 2, level: 1, name: 'B'},
{id: 3, level: 1, name: 'S'},
{id: 4, level: 0, name: 'A'},
{id: 5, level: 0, name: 'S'},
{id: 7, level: 0, name: 'B'}, ]
Due to limitations with ecmaScript-5, I am unable to use .includes which could have been helpful in this case.
Furthermore, I prefer to utilize the .filter function. Any suggestions on how to achieve this?
Thank you.