Skip to content

Instantly share code, notes, and snippets.

@genpri
Forked from JoaoCnh/triforce.js
Created April 3, 2019 13:35
Show Gist options
  • Save genpri/2bc35a41c24c843097554771f9c9c29a to your computer and use it in GitHub Desktop.
Save genpri/2bc35a41c24c843097554771f9c9c29a to your computer and use it in GitHub Desktop.

Revisions

  1. @JoaoCnh JoaoCnh revised this gist Feb 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion triforce.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ const songNames = allSongs.reduce((acc, currValue) => {
    })
    // Let's filter the ones under 3 minutes
    .filter(song => {
    return song.duration >= 3;
    return song.duration > 3;
    })
    // Now let's map out the song names the quick way
    .map(song => song.name).join(" , ");
  2. @JoaoCnh JoaoCnh created this gist Feb 14, 2018.
    16 changes: 16 additions & 0 deletions triforce.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // 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