How do I delete the corresponding element by name in js, and there is more than one?

how to delete the corresponding element by name in

js, and there is more than one, which is similar to checkbox inverting

.

example:

let arr = ["a","b","c","d","e"];

suppose you want to delete an and b, what should you do? ask passing bosses

Dec.16,2021

let index;
while ((index = arr.findIndex(n => /^(a|b)$/.test(n))) > -1) arr.splice(index, 1);
Menu