title: How to update one array with data from another array in Javascript using Key of Id?
body: <p>I have two arrays in Javascript, I need to update the first array with the contents of the second array using the key of id. </p>
  
  <p>I need to find the id from the array and update the same object.</p>
  
  <p>since b is an array of a single object, I can use b[0].id </p>
  
  <pre><code>const a = [{id: 1, name: 'test', data: 'yes'}, {id: 2, name: 'test 1'}]
  
  const b = [{id: 1, name: 'sample', data: 'no'}, {id: 3, name: 'sample', data: 'no'}]
  
  const output = [{id: 1, name: 'sample', data: 'no'}, {id: 2, name: 'test 1'}, {id: 3, name: 'sample', data: 'no'}]
  </code></pre>
  
  <p>Any help will be appreciated</p>