I have just started learning the array methods in javascript. I want to delete elements in an array based on another array. I tried with the below approach but didn't get the expected result.
const array1 = [1, 2, 3, 4, 5, 6, 7];
const array2 = [2, 4, 5];
array2.forEach(a2 => {
array1.filter(a1 => a1 !== a2)
})
console.log(array1);
// actual output: Array [1,2,3,4,5,6,7];
// expected output: Array [1,3,6,7]
Which would be the best array method suited here?