information = { boxNoTo: 1, boxNoFrom: 1, size: 'M', }
items = [{ size: 'M', },{ size: 'M', },{ size: 'S,M,L,XS', boxNoTo: 1, boxNoFrom: 1, country: 'CA', name: 'Josh' }]
This is what I have done
const INDEX = items.findIndex((x) => {
if (x.size.split(',').length > 0) {
return (
x.size.split(',').filter((y) => y === information['size'])[0] ===
information['size'] &&
x.boxNoFrom === information['boxNoFrom'] &&
x.boxNoTo === information.boxNoTo
);
} else {
return (
x.size === information['size'] &&
x.boxNoFrom === information['boxNoFrom'] &&
x.boxNoTo === information.boxNoTo
);
}
});
My goal is to find the index of
{
size: 'S,M,L,XS',
boxNoTo: 1,
boxNoFrom: 1,
country: 'CA',
name: 'Josh'
}