Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function convertPlaylistToObjectByProperty(simplifiedPlaylist, propertyName){
//use to group large array of tracks into smaller arrays of tracks from same album
//this lets us easily sort tracks for a single album, then do a loop
//over each albumId as an object key and combine the arrays back together
let playlistObject = {};
//eslint-disable-next-line => {
if (!playlistObject[track[propertyName]]) {
playlistObject[track[propertyName]] = [];
//now sort the array in each property by trackNumber, so tracks play in the same order as the album
for (let relatedTrackArray in playlistObject) {
return playlistObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment