I am working on a data format transformation which showed on the title, but I don't know how to figure out. I have tried to write the blow code to add the variable name for second dimensional array:

```
const data = [
  { id: 1, var1: 'val1', var2: 'val2', varX: ['time1', 'time2', 'time3'] },
  { id: 2, var1: 'val2', var2: 'val3', varX: ['time4', 'time5', 'time6'] },
];

const test = data.map((o) => o.varX);

for (i = 0; i < test.length; i++) {
  const test2 = test[i].reduce((res, cur, idx) => {
    res[`varX${idx}`] = cur;
    return res;
  }, {});
  console.log(test2);
}

```

but what I expected result should be:

```
[{id:1, var1:val1, var2:val2, varX1:time1, varX2:time2, varX3:time3},{id:2, var1:val2, var2:val3, varX1:time4, varX2:time5, varX3:time6}]

```

Could anyone can guide me how to convert the data?