Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solving the problem
// Let's reduce the array of arrays into a single one
const songNames = allSongs.reduce((acc, currValue) => {
return acc.concat(currValue);
}, [])
// Let's map it out with the seconds turned into minutes
.map(song => {
return { ...song, duration: Math.floor(song.duration / 60) };
})
// Let's filter the ones under 3 minutes
.filter(song => {
return song.duration > 3;
})
// Now let's map out the song names the quick way
.map(song => song.name).join(" , ");
console.log(songNames); // Oblivion , Flying Whales , L'Enfant Sauvage , Out of the Black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.