I need convert Array of Array of Objects into a simple Array of objects using JavaScript
Below i go put the current code with the current output
const result = [
[
{
name: '1'
},
{
name: '2'
}
],
[
{
name: '3'
},
{
name: '4'
}
],
[
{
name: '5'
}
],
[
{
name: '6'
}
]
]
const a = result.map(item => {
return Object.assign({}, ...item)
})
console.log(a)
Output of the above code (current and wrong output)
[ { "name": "2" }, { "name": "4" }, { "name": "5" }, { "name": "6" } ]
The expected and needed output
[
{
name: '1'
},
{
name: '2'
},
{
name: '3'
},
{
name: '4'
},
{
name: '5'
},
{
name: '6'
}
]