This is the result I'm looking for:
Input : [
[
{a: [v]},
{b: [v]}
],
[
{c: [v]},
{d: [v]}
]
]
Output : [
{
a: [v],
c: [v]
},
{
a: [v],
d: [v]
},
{
b: [v],
c: [v]
},
{
b: [v],
d: [v]
}
]
First it is an array of arrays made with objects. Then it turns to an array of objects. Each combination can have one element of each original array only. My attempt is the following:
arr.forEach((d, i) => {
d.forEach((l, j) => {
temp[j] ? temp[j].push(l) : temp[j] = [l];
});
});
But I haven't figured out yet how to do it.