If i select an image it will add to array and if i deselect this image after selecting another photos, it won't delete from array, but i want only those selected items that are inserted to an array
const selectItem = (event, img) => {
let element = event.target;
element.classList.toggle('added');
const index = sliders.indexOf(img);
if (index === -1) {
sliders.push(img);
} else {
sliders.splice(img, 1);
}
}