I have an array that I am mapping over to create a list. When a user clicks one element I need to create an array with the index of all elements in that array. Then if an item at one of those indexes is clicked it is removed from the array. I am having trouble figuring out a method for creating the array of all indexes. My component is being sent each index one by one from a map so Ive tried pushing each index into an array but I end up with an array with only 1 index:
items = [{type
items.map((item, idx) => {
let indexes = [{type: "clickable", time: "11:41pm"}{type: "standard", time: "11:42pm"},{type: "clickable", time: "11:43pm"}, {type: "clickable", time: "11:45pm"}]
if(item.type == "clicklable"){
indexs.push(idx)
}
console.log(indexes)
// [0]
// [2]
// [3]
}
How can I add all the indexes to one array?