Good afternoon everyone, I have the following arrangement:
const aDatos = [
{ v: 1 },
{ v: 2 },
null,
{ v: 3 },
{ v: 4 },
{ v: 5 },
null,
{ v: 6 },
{ v: 7 },
{ v: 8 },
{ v: 9 },
{ v: 10},
];
const encabezados = ["data1", "data2", "data3", "data4"];
and I want to group the data with custom properties, the ones that come in the second array (headers) in such a way that it looks like this:
[
{
data1: { v: 1 },
data2: { v: 2 },
data3: null,
data4: { v: 3 },
},
{
data1: { v: 4 },
data2: { v: 5 },
data3: null,
data4: { v: 6 },
},
{
data1: { v: 7 },
data2: { v: 8 },
data3: { v: 9 },
data4: { v: 10},
},
]
I am trying this way but it doesn't fit as I intend.
const o = datta.map(function (e) {
var obj = {};
keys.forEach(function (key) {
obj[key] = e;
});
return obj;
});
In advance, I appreciate the suggestions you can give me to solve the problem.
Cheers