title: Making an array of object a value of a object in Array in Node.js
body: <p>I have two arrays of objects. example</p>
  
  <pre><code> data1 = [{
       foo: '2',
       box: 'yes',
       id: '1234'
   }, {
       foo: '34',
       box: 'no',
       id: '1235'
   }];
  
   data2 = [{
       key: 'value',
       key: 'value',
       id: '1234'
   }, {
       key: 'value',
       key: 'value',
       id: '1235'
   }];
  </code></pre>
  
  <p>I need it like this based on matching id value :
  each obj has a unique key id, that much the second array.</p>
  
  <pre><code>finalData = [{
      foo: '2',
      box: 'yes',
      id: '1234',
      key: 'value',
      key: 'value'
  }, {
      box: '34',
      box: 'no',
      id: '1235',
      key: 'value',
      key: 'value'
  }];
  </code></pre>
  
  <p>basically merging the two arrays of objects based on key id .</p>