I would like to remove multiple items from an array by an array of indexes.
const indexes = [0, 1, 3];
const values = [0, 1, 2, 3, 4, 5];
indexes.forEach((idx) => {
values.splice(idx, 1);
});
console.log(values);
When looping for the second time, the index is wrong because the array is shorter.
What should I do so the outcome would be [2, 4, 5]
?