Build a Playlist Remix Engine - Build a Playlist Remix Engine

Though is not clear, what I did was to randomize the tracks for the output, it worked well for me:

function remixPlaylist(arr1,max){
  const flat = flattenPlaylists(arr1);
  const scores = scoreTracks(flat);
  const dedupe = dedupeTracks(scores);
  const quota = enforceArtistQuota(dedupe,max);
  const arr = buildSchedule(quota);

  const result = [];
  const already = [];
  while (result.length < arr.length){
    const indice = Math.floor(Math.random()*arr.length)
    if(!already.includes(indice)){
      already.push(indice)
      result.push(arr[indice])
    }
    
  }
  console.log(result)
  return result;
}

// running tests
// tests completed
// console output
[ { slot: 3, trackId: 'trk103' },
  { slot: 1, trackId: 'trk101' },
  { slot: 4, trackId: 'trk201' },
  { slot: 2, trackId: 'trk102' } ]