1

In javascript, I simply need to compare:

Array2 = ['a', 'd'] 

with

Array1=['a','b','c','d','e'] //full subset 

and return a new array of items which are not in Array 1. so the result should be

Array3 = ['b','c','e']

Appreciate a quick reply. Many thanks in advance

  • effort so far ? please post the code you tried so far ? – Code Maniac Sep 04 '19 at 19:02
  • 1) please don't ask us to do your homework for you. your answers will be better received if you show some effort instead of just asking for free code. 2) the least amount of effort you can show is a simple google search. – I wrestled a bear once. Sep 04 '19 at 19:03

1 Answers1

1

Use a combinations of filter and includes likes so:

let newArray = Array1.filter(x => !Array2.includes(x));
cullanrocks
  • 457
  • 4
  • 16