Skip to content

Instantly share code, notes, and snippets.

@lvngd
Created February 27, 2021 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvngd/ccb12bc49372b95c670774e3660a391f to your computer and use it in GitHub Desktop.
Save lvngd/ccb12bc49372b95c670774e3660a391f to your computer and use it in GitHub Desktop.
function flattenData(data){
let flatData = [];
data.forEach(band => {
band.bandAlbums.forEach(album => {
album.albumSongs.forEach(song =>{
flatData.push({bandName: band.bandName,
bandUrl: band.bandUrl,
albumName: album.albumName,
albumType: album.albumType,
albumYear: album.albumYear,
songName: song.songName,
songUrl: song.songUrl
});
});
});
});
return flatData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment