I have two arrays of objects and I want to create a new array of objects where every object is a merged version from previous two objects, for example:
const one = [
{ id: 1, title: 'One' },
{ id: 2, title: 'Two' }
]
const two = [
{ status: 'Open' },
{ status: 'Close' }
]
From above arrays I'll expect:
const result = [
{ id: 1, title: 'One', status: 'Open' },
{ id: 1, title: 'Two', status: 'Close' }
]
The question here is I don't know how to create a function that actually can receive n arrays of objects and creates the new one, for example if I wanna to merge a third array:
const three = [
{ items: 10 },
{ items: 2 }
]
I'll expected the following array:
const result = [
{ id: 1, title: 'One', status: 'Open', items: 10 },
{ id: 1, title: 'Two', status: 'Close', items: 2 }
]
I think that actually I can create a function that receive a spread but I don't know how to merged every object from every array recived into the function.