Sorry I don't know how to word that title.
I want to transform the following data structure :
raw = [
{'id': 1, 'tilt': [tilt1_1, ..., tilt9_1]},
{'id': 2, 'tilt': [tilt1_2, ..., tilt9_2]},
...
{'id': n, 'tilt': [tilt1_n, ..., tilt9_n]},
];
Into :
tilts = [
[tilt1_1, ..., tilt1_n],
[tilt2_1, ..., tilt2_n],
...
[tilt9_1, ..., tilt9_n],
];
I have the following working solution:
tilts = [[], [], [], [], [], [], [], [], []];
for (let i = 0; i < raw.length; i++) {
for (let j = 0; j < tilts.length; j++) {
tilts[j].push(raw[i]['tilt'][j]);
}
}
Is there a cleaner or more idiomatic way of achieving this ?