General Assembly Logo

JS Finite State Machine Challenge

For this challenge, you will create a simple Finite State Machine.

Prerequisites

Instructions

  1. Fork and clone this repository.
  2. Change into the new directory.
  3. Install dependencies.
  4. Create and checkout a new branch to work on.
  5. Fulfill the listed requirements.

Starter code is available in lib/challenge.js. A pull request is not required, but it is necessary if you want a code review.

You may wish to refer to FAQs related to forking and cloning.

Requirements

Implement SubwayGate, a function that represents a finite-state machine. In this scenario our machine is the gate at the subway and can only exist in two states: open and closed. The gate only opens for the following reasons:

  • a Charlie Card is tapped on the gate
  • a ticket is inserted into the gate with enough money to get on the T ($2.25)
  • a person is exiting the station If the gate is open, then tapping the card again will not transition the state to closed. The state transitions to closed upon a person walking through the gates.

Tasks

Developers should run these often!

  • grunt nag or just grunt: runs code quality analysis tools on your code and complains.
  • grunt make-standard: reformats all your code in a standard style.
  • grunt test: runs any automated tests; may depend on grunt build.
  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact legal@ga.co.