I have a planning, with multiple items. My object is like this :
planning: [
{ id: '1', equipe: [ '1', '2' ] },
{ id: '2', equipe: [ '1' ] },
{ id: '3', equipe: [ '2', '3' ] }
...
]
I want to filter this array to hide or show planning items. My shown array is :
checked: [ '1', '4' ]
So, the array planning could be filtered by equipe array, so it should be :
planning: [
{ id: '1', equipe: [ '1', '2' ] },
{ id: '2', equipe: [ '1' ] }
]
I've tried to filter array but I don't see how indexOf could work with array and not string. I've also tried includes function but this doens't work:
planning.filter(item => checked.includes(item.equipe))
Thask for help !
planning.filter(item => checked.includes(item.equipe))In this you are not checking if any element from checked array is present within the equipe instead you are checking whether checked contains the equipe array itself.