its_me
0
Q:

javascript remove multiple items from array

var colors=["red","green","blue","yellow"];
//loop back-words through array when removing items like so:
for (var i = colors.length - 1; i >= 0; i--) {
    if (colors[i] === "green" || colors[i] === "blue") { 
        colors.splice(i, 1);
    }
}
//colors is now  ["red", "yellow"]
5
const nums = [1, 2, 3, 4, 5, 6];
const remove = [1, 2, 4, 6];

function removeFromArray(original, remove) {
  return original.filter(value => !remove.includes(value));
}
2

New to Communities?

Join the community