Skip to content

Instantly share code, notes, and snippets.

@Kos-M
Last active July 18, 2021 18:23
Show Gist options
  • Save Kos-M/8bd489de4fed6afd322c7e48aaa2397f to your computer and use it in GitHub Desktop.
Save Kos-M/8bd489de4fed6afd322c7e48aaa2397f to your computer and use it in GitHub Desktop.
Js Simple Convert object of Objects to Array of Objects
const initial = {
BTC: {
available: '0.00000000',
onOrder: '0.00000000',
},
LTC: {
available: '0.00000000',
onOrder: '0.00000000',
},
};
const result = Object.keys(initial).map((i) => ({ [i]: initial[i] }));
// result is :
// [
// { BTC: { available: '0.00000000', onOrder: '0.00000000' } },
// { LTC: { available: '0.00000000', onOrder: '0.00000000' } }
// ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment