-2
const arr1 = ["a", "b", "c", "d", "e"];
const arr2 = ["b", "d"];

I need to do something which remove "b" and "d" from arr1. Of course I need to remove elements from arr1 which exist in arr2 too.

1 Answers1

2

Try using filter + includes:

const arr1 = ["a", "b", "c", "d", "e"];
const arr2 = ["b", "d"];

let result = arr1.filter(el => !arr2.includes(el));
console.log(result);
mickl
  • 48,568
  • 9
  • 60
  • 89