Tell us what’s happening:
I can’t get Test 3 to pass. I’ve checked what other people have done with the flattenPlaylists function, and I seem to be doing it just like they are. I’m really not sure why this test is failing. My output shows the required indices. What am I missing? I appreciate any help I can get.
Your code so far
const playlists = [
[
{
trackId: "trk101",
artist: "Velvet Comet",
title: "Crimson Afterglow",
votes: 5,
bpm: 122
},
{
trackId: "trk102",
artist: "Neon Harbor",
title: "Static Horizon",
votes: 2,
bpm: 108
},
{
trackId: "trk103",
artist: "Lunar Arcade",
title: "Midnight Frequency",
votes: 4,
bpm: 128
}
],
[
{
trackId: "trk201",
artist: "Solar Echo",
title: "Glass Skyline",
votes: 3,
bpm: 115
},
{
trackId: "trk202",
artist: "Velvet Comet",
title: "Satellite Hearts",
votes: 6,
bpm: 124
}
]
];
function flattenPlaylists(array) {
let newArray;
if (!Array.isArray(array)) {
return [];
}
for (let i = 0; i < array.length - 1; i++) {
newArray = array[i].concat(array[i + 1]);
}
for (let entry of array) {
for (let obj of entry) {
obj.score = [array.indexOf(entry), entry.indexOf(obj)];
}
}
return newArray;
}
console.log(flattenPlaylists(playlists));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36
Challenge Information:
Build a Playlist Remix Engine - Build a Playlist Remix Engine