Created
February 14, 2018 15:18
-
-
Save JoaoCnh/0dde17e75ff4549114dfc6d492f99d88 to your computer and use it in GitHub Desktop.
Solving the problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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