Skip to content

Instantly share code, notes, and snippets.

@Alamin02
Created April 1, 2020 08:08
Show Gist options
  • Save Alamin02/ede6b5dfdee50e577c6539cacbaeabd2 to your computer and use it in GitHub Desktop.
Save Alamin02/ede6b5dfdee50e577c6539cacbaeabd2 to your computer and use it in GitHub Desktop.
const input = {
page1: {
group1: [{ url: 'test1' }, { url: 'test2' }],
group2: [{ url: 'test3' }, { url: 'test4' }],
},
page2: {
group1: [{ url: 'test5' }, { url: 'test6' }],
group2: [{ url: 'test7' }, { url: 'test8' }],
},
};
const formatData = input => {
output = []
for (const groups of Object.values(input)) {
for (const urlList of Object.values(groups)) {
output.push(...urlList);
}
}
return output;
}
console.log(formatData(input))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment