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.
I need to find the id from the array and update the same object.
since b is an array of a single object, I can use b[0].id
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'}]
Any help will be appreciated