-1

I have following two arrays

let a = ["Hello", "bye", "good morning", "test"];
let b = ["Hello", "test"];

How can i delete items that exists in array b from array a(without mutation)? The resultant array should look like:-

["bye", "good morning"];
TOM
  • 51
  • 3

1 Answers1

3

filter() and some()

let a = ["Hello", "bye", "good morning", "test"],
    b = ["Hello", "test"],
    c = a.filter( e => !b.some( i => i===e))
epascarello
  • 204,599
  • 20
  • 195
  • 236