atleast one of the value’s in the array1 obj “data” array matches the “data” array in array2 object

at least one of the value’s in the array1 obj “data” array matches the “data” array in array2 object


> array1

array1 = [
  {
      id: '1',
      name: 'ron',
      data: ['p1']
  },
  {
      id: '2',
      name: 'lon',
      data: ['p2']
  },
{
      id: '3',
      name: 'voon',
      data: ['p4']
  }
];


> array2

array2 = [
  {
      id: '1',
      name: 'fgr',
      data:['p1','p2','p3']
  },
  {
      id: '2',
      name: 'gone',
      data:['p1','p2','p3']
  }
]


output: {
id: ‘1’,
name: ‘ron’,
data: [‘p1’]
},
{
id: ‘2’,
name: ‘lon’,
data: [‘p2’]
}