The information is structured as follows:
const dataset = [
{'x': '1', 'y': '2', 'z': '3'},
{'x': '10', 'y': '20', 'z': '30'}
]
I am aiming for the following structure:
const xArray = ['1','10']
,yArray = ['2', '20']
,zArray = ['3', '30']
This approach was taken:
...
return {
xArray: _.values(_.mapValues(dataset, 'x'))
yArray: _.values(_.mapValues(dataset, 'y'))
zArray: _.values(_.mapValues(dataset, 'z'))
}
While it successfully achieves the desired outcome, there may be room for a cleaner implementation. What would be the most efficient way to group an object by multiple keys?