I am trying to write a function to take the first object in the "parent" array, pull out the child field (which is in that array) and use that field to filter the second object called "child".

I want to get all the related records from the child object that are in the child field in the parent object.

Expected output

```
  child: [
    {
      **id: 1,**
      name: 'Jimmy Yukka',
    },
    {
      **id: 2,**
      name: 'Up North',
    }

```

INPUT

```
 Parent: [
    {
      **id: 1,**
      name: 'Melbourne Bands',
      **child: [1, 2]**
    }

```

I have the following data

```
 Parent: [
    {
      **id: 1,**
      name: 'Melbourne Bands',
      **child: [1, 2]**
    },
    {
      id: 2,
      name: 'Sydney Bands',
      child: [3]
    }
  ],
  child: [
    {
      **id: 1,**
      name: 'Jimmy Yukka',
    },
    {
      **id: 2,**
      name: 'Up North',
    },
    {
      id: 3,
      url: 'jimmyyukka.com',
      name: 'INXS',
      CreatedByUserId: 1
    }
  ],

```

The code of the function I have implemented so far:

```
  currentChildrenIds(ParentId, parentData, childData) {
    const singleParentRecord = parentData.filter(function(parent) {
      return parent.id === ParentId;
    });
    const parentsChildIds = singleParentRecord[0].books;

    const childRecords = childData.filter(function(child) {
      return child.id === parentsChildIds
    });

    return childRecords
  }

```

**NOTES**
This bit here is where it is wrong

```
const childRecords = childData.filter(function(child) {
      return child.id === parentsChildIds

```

This bit here is also a bit rubbish (hardcoding the [0])but not I'm not sure how I should be coding it correctly

```
 const parentsChildIds = singleParentRecord[0].books;

```