I'm trying to filter one array so that the objects will display if they match one of the options at the filterOptions (another array).
Example: If filterOptions contains the string big it should show the objects with sizes containing the string big
However, I'm not sure how to split data.sizes correctly so it can use this data to filter with, how can I do this?
https://codesandbox.io/s/thirsty-ellis-dplhg
export const App = () => {
const data = [
{sizes: 'big,small',},
{sizes: 'medium,small'},
{sizes: 'small,big',},
{sizes: 'big',},
{sizes: 'medium',}
];
const filterOptions = ['big', 'small'];
const splitData = data.map(items => items.sizes.split(','));
return(
<div>
{console.log(splitData)}
{data.filter(items => items.sizes.includes(filterOptions))
.map(item => <div>{item.sizes}<br /></div>)}
</div>
)
}
sizes: 'big'pass even though 'small' isn't in it?