1

The other posts I've seen deals with 1D Arrays, so...

Array1

[
 ["PE","151"],
 ["PE","160"],
 ["PE","188"]
]

Array 2

[
 ["PE","193"],
 ["PE","173"],
 ["PE","188"]
]

Expected Result

[
 ["PE","151"],
 ["PE","160"]
]

I've tried using filter, but I'm not sure I can get the element to compare.

const newItems = Array1.filter(el => Array2[1].indexOf(el[1]) === -1)

Thanks!

onit
  • 2,275
  • 11
  • 25
  • 1
    This question was closed but the suggested answer does not work for this situation. Can someone please reopen as I have a simple solution. – TheWizEd Mar 11 '22 at 22:14
  • hi, @TheWizEd! Ended using it ```let newItems = array1.filter(function (val) { return array2.every(function (item) { return (val[1] !== item[1]); }) });``` Thanks for trying! – onit Mar 11 '22 at 23:14
  • 1
    Glad you figured out a solution – TheWizEd Mar 12 '22 at 18:18

0 Answers0