Giter Site home page Giter Site logo

bhabig / javascript-pure-functions-lab-learn-experts-testing-batch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pickledyamsman/javascript-pure-functions-lab-learn-experts-testing-batch

0.0 2.0 0.0 9 KB

License: Other

Shell 8.09% HTML 18.88% JavaScript 73.03%

javascript-pure-functions-lab-learn-experts-testing-batch's Introduction

JavaScript Pure Functions Lab

Overview

In this lab, you'll write non-side-effecting functions and you'll chain updates without mutating global state.

Late to the party

Let's pretend we've been living under a rock for the last couple of months, and haven't been keeping up with the latest TV shows. Our friend tells us that the latest season of Game of Thrones has been released for quite some time now. Why were we not informed of this sooner?! It's time for some good 'ol binge watching!

Tyrion dancing

In the index.js file, there is a list of episodes, as well as the finale episode in a separate variable. Your tasks for this lab are as follows:

  1. Create a addToPlaylist() function that takes a playlist and an episode as arguments, and returns a new array with the episode appended to the playlist. This function must not modify the original array! This function is used to create a playlist that also contains the finale episode.

  2. Create a removeFromPlaylist() function that takes a playlist and an episode, and returns a new array with that episode removed from the array. This function must also not modify the original array.

  3. Create a getNextEpisodeInPlaylist() function that returns the first episode in a playlist.

  4. Finally, to tie it all together, create a function called bingeWatch() that takes a playlist as its only argument. This function recursively calls itself: as long as there is a next episode, we watch it (by removing it from the playlist), and then we continue our binge watching session. If there are no more episodes in the playlist, we return the string 'Please let there be more!'. Sadly for us, there aren't any more episodes in this season. Such a long wait.

NOTE: Unfortunately, due to JavaScript quirks, you'll need to write bingeWatch() with function syntax for the tests to pass:

function bingeWatch() { ... }

In the "real world," using an arrow function would be fine โ€”

const bingeWatch = () => { ... }

โ€” but it won't work here.

Resources

javascript-pure-functions-lab-learn-experts-testing-batch's People

Contributors

annjohn avatar bhabig avatar joshuabamboo avatar pletcher avatar thomastuts avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.