I have a scenario where user can multiselect items and remove them, so I have two arrays:
- With checkbox values (checked and index)
- The actual items which need to filter based on checked values index.
here are two arrays and expected result using lodash.
const checked = [
{
index: 0,
checked: false
},
{
index: 1,
checked: true //note second index is checked so we need to filter out second index from items array.
},
];
const items = [
{
title: 'This is title 1',
description: 'This is description 1',
end_date: '2018-03-12 14:00:00',
location: '3577 Rue de Bullion, Montréal, QC H2X 3A1, Canada',
room: 401,
start_date: '2018-03-12 13:00:00',
},
{
title: 'This is title 2',
description: 'This is description 2',
end_date: '2018-03-12 14:00:00',
location: '3577 Rue de Bullion, Montréal, QC H2X 3A1, Canada',
room: 401,
start_date: '2018-03-12 13:00:00',
}
];
const result = [
{
title: 'This is title 1',
description: 'This is description 1',
end_date: '2018-03-12 14:00:00',
location: '3577 Rue de Bullion, Montréal, QC H2X 3A1, Canada',
room: 401,
start_date: '2018-03-12 13:00:00',
}
];