Skip to content

Instantly share code, notes, and snippets.

@abel-masila
Created September 7, 2018 10:34
Show Gist options
  • Save abel-masila/b5eb8dde25a96731dcfa4d4dfb946d30 to your computer and use it in GitHub Desktop.
Save abel-masila/b5eb8dde25a96731dcfa4d4dfb946d30 to your computer and use it in GitHub Desktop.
const variants=[
{"id":1,"name":"shoes","color":"red"},
{"id":2,"name":"food","color":"blue"},
{"id":3,"name":"car","color":"yellow"},
];
// I want to extract the keys and values from this data and create a new array which looks like:
// newAyy=[
// {id:["1","2","3"]},
// {name:["shoes","food","car"]},
// {color:["red","blue","yellow"]}
// ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment