i was wondering if there is quick solution (using map() for example) to convert a multidimensional array to a single dimensional array, that still keeps all information of the original array.
You can solve it with some loops, but i think there must be a smarter solution.
To explain it a bit more here is an example:
const arr = [{
id: 1,
people: [
{name: "x", surname: "x"},
{name: "y", surname: "y"}
]
},{
id: 2,
people: [
{name: "a", surname: "a"},
{name: "b", surname: "b"}
]
}]
const result = [
{id: 1, name: "x", surname: "x"},
{id: 1, name: "y", surname: "y"},
{id: 2, name: "a", surname: "a"},
{id: 2, name: "b", surname: "b"}
]