The title is a little bit confusing but I essentially want to convert this:
[
{a: 1, b: 2, c:3},
{a: 4, b: 5, c:6},
{a: 7, b: 8, c:9}
]
into:
{
a: [1,4,7],
b: [2,5,8],
c: [3,6,9]
}
using lodash (requirement). Any ideas???
The title is a little bit confusing but I essentially want to convert this:
[
{a: 1, b: 2, c:3},
{a: 4, b: 5, c:6},
{a: 7, b: 8, c:9}
]
into:
{
a: [1,4,7],
b: [2,5,8],
c: [3,6,9]
}
using lodash (requirement). Any ideas???
Here's a solution using lodash that maps across the keys and plucks the values for each key from the data before finally using _.zipOobject to build the result.
Look for
_.map
here