Difference between two arrays based on some the value inside a nested array

I have two arrays of objects, and what I need to do is create a new array based on arrayOfItems where it doesn’t include the same value found in itemX[0].nestedArrayOfItems

However, whats throwing me for a loop here is I don’t know how to handling filtering when the keys in itemX[0].nestedArrayOfItems could be anything.

Usually it be a common key like id and you could just go
const results = arrayOfItems.filter(item => !itemX[0].nestedArrayOfItems.some(({ id }) => id === item.id)) but sadly it’s not the case and gap in my knowledge means I can’t figure it out.

const arrayOfItems = [
  {
  id: '4321-3321-4423', 
  value: 'some text'
  },

  {
  id: '4322-4654-9875', 
  value: 'some text again'
  }
]

const itemX = [
  {
  id: '3214-6543-4321', 
  nestedArrayOfItems: [
      {"1" : '4321-3321-4423'},
      {"2" : '3455-8765-7764'}
  ]
  }
]

Would you be able to link the challenge?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.