title: Update the array with attributes from different array with same key for both - javascript
body: <p>I have the following array which is assumed to be large data set.</p>
  <pre><code>let response1 = [
    { userID: '2222', dataOne: [ [Object], [Object] ] },
    {
      userID: '6666',
      dataOne: [ [Object] ],
      dataTwo: [ [Object], [Object] ]
    },
    {
      userID: '11111',
      dataOne: [ [Object], [Object] ],
      dataTwo: [ [Object] ]
    },
    { userID: '4586', dataTwo: [ [Object] ] }
  ];
  </code></pre>
  <p>I have another array which i got as a result of database query (which is also a large data set)</p>
  <pre><code>let dbResponse  = [{
    &quot;attributes&quot;: {
      &quot;dob&quot;: &quot;19890147&quot;,
      &quot;gender&quot;: &quot;M&quot;,
      &quot;mobilePhone&quot;: &quot;1239000000&quot;,
      &quot;name&quot;: &quot;Ketan Hol&quot;,
    },
    &quot;doctorID&quot;: &quot;ds45ds&quot;,
    &quot;userID&quot;: &quot;11111&quot;
  },
  {
    &quot;attributes&quot;: {
      &quot;dob&quot;: &quot;19890386&quot;,
      &quot;gender&quot;: &quot;M&quot;,
      &quot;mobilePhone&quot;: &quot;1239000000&quot;,
      &quot;name&quot;: &quot;Sachin&quot;,
    },
    &quot;doctorID&quot;: &quot;erjjkrel&quot;,
    &quot;userID&quot;: &quot;6666&quot;
  },
  {
    &quot;attributes&quot;: {
      &quot;dob&quot;: &quot;19890219&quot;,
      &quot;gender&quot;: &quot;M&quot;,
      &quot;mobilePhone&quot;: &quot;1239000000&quot;,
      &quot;name&quot;: &quot;Vishwas&quot;,
    },
    &quot;doctorID&quot;: &quot;dfgfdg&quot;,
    &quot;userID&quot;: &quot;2222&quot;
  },
  {
    &quot;attributes&quot;: {
      &quot;dob&quot;: &quot;19890219&quot;,
      &quot;gender&quot;: &quot;M&quot;,
      &quot;mobilePhone&quot;: &quot;1239000000&quot;,
      &quot;name&quot;: &quot;Jis&quot;,
    },
    &quot;doctorID&quot;: &quot;dfgfdg&quot;,
    &quot;userID&quot;: &quot;98645&quot;
  },
  {
    &quot;attributes&quot;: {
      &quot;dob&quot;: &quot;19890219&quot;,
      &quot;gender&quot;: &quot;M&quot;,
      &quot;mobilePhone&quot;: &quot;1239000000&quot;,
      &quot;name&quot;: &quot;Brad&quot;,
    },
    &quot;doctorID&quot;: &quot;dfgfdg&quot;,
    &quot;userID&quot;: &quot;4586&quot;
  },
      {
            &quot;attributes&quot;: {
              &quot;dob&quot;: &quot;19890219&quot;,
              &quot;gender&quot;: &quot;M&quot;,
              &quot;mobilePhone&quot;: &quot;1239000000&quot;,
              &quot;name&quot;: &quot;Brad&quot;,
            },
            &quot;doctorID&quot;: &quot;dfgfdg&quot;,
            &quot;userID&quot;: &quot;4586&quot;
          }
  
  ];
  </code></pre>
  <p>I need to add the attributes such as dob, name from dbResponse to response1 array based on same userID.
  All the userID in response1 array should be populated with attributes like dob, name from dbResponse. I am confused on how to perform the below in large data set.</p>
  <p>Expected output will be like this:</p>
  <pre><code>response1 = [
        { userID: '2222', dataOne: [ [Object], [Object] ], dob: '19890219', name: 'Vishwas' },
        {
          userID: '6666',
          dataOne: [ [Object] ],
          dataTwo: [ [Object], [Object] ],
          dob: '19890386',
          name: 'Sachin'
        },
        {
          userID: '11111',
          dataOne: [ [Object], [Object] ],
          dataTwo: [ [Object] ],
          dob: '19890147',
          name: 'Ketan Hol'
        },
        { userID: '4586', dataTwo: [ [Object] ], dob: '19890219', name: 'Brad' }
      ];
  </code></pre>
  <p>What will be the best way to achieve this using es6 functions for a large data sets? I am new to these es6 functions. Any help would be really appreciated.</p>