I am dealing with an input array of objects
[
{ col1: 'col1value1', col2: 'col2value1', col3: col1value3},
{ col1: 'col1value2', col2: 'col2value2', col3: col1value2}
]
My goal is to transform this into two arrays structured as follows:
columns:["col1" , "col2","col3"],
data: ["col1value1","col2value1" , "col1value3"] ,
["col1value2","col2value2" , "col1value2"]
I am currently using a method involving nested foreach loops to achieve this. Is there a more efficient or faster approach?