Skip to content

Instantly share code, notes, and snippets.

@JoaoCnh
Created February 14, 2018 15:18
Show Gist options
  • Save JoaoCnh/0dde17e75ff4549114dfc6d492f99d88 to your computer and use it in GitHub Desktop.
Save JoaoCnh/0dde17e75ff4549114dfc6d492f99d88 to your computer and use it in GitHub Desktop.
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