Created
July 4, 2017 02:49
-
-
Save Louiefigz/18e9d3ef6c0c68e346ea65acc678d24a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const episodes = [ | |
| { id: 's06e01', title: 'Pilot' }, | |
| { id: 's06e02', title: 'Top Banana' }, | |
| { id: 's06e03', title: 'Charity Drive' }, | |
| { id: 's06e04', title: 'Visiting Ours' }, | |
| { id: 's06e05', title: 'My Mother, the Car' }, | |
| { id: 's06e06', title: 'In God We Trust' }, | |
| { id: 's06e07', title: 'Storming the castle' }, | |
| { id: 's06e08', title: 'Pier Pressure' }, | |
| { id: 's06e09', title: 'Public Relations' }, | |
| ]; | |
| const finaleEpisode = { id: 's06e10', title: 'Bringing Up Buster' }; | |
| const addToPlaylist = (playlist, episode)=>playlist.concat([episode]); | |
| const removeFromPlaylist = (playlist, episode)=>playlist.filter(e=>e.id !== episode.id); | |
| const getNextEpisodeInPlaylist = (episodes)=>episodes[0]; | |
| function bingeWatch(episodes){ | |
| if(episodes.length==0){ | |
| return 'Please let there be more!'; | |
| } | |
| const nextEpisode = getNextEpisodeInPlaylist(episodes); | |
| console.log(nextEpisode) | |
| console.log(episodes.length) | |
| return bingeWatch(removeFromPlaylist(episodes, nextEpisode) ); | |
| } | |
| bingeWatch(addToPlaylist(episodes, finaleEpisode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment