Share your repls and programming experiences

← Back to all posts
functor-test
uzurpator (0)

Decide if giving context matches to the set of rules and return the Screen name

context is just an ordinary JavaScript object which can or can not contain specific data.

There are 4 functions goConfirm, goBonuses, goReturns, goShipments one can user to decide whether giving context fits fully to the specific set of rules.

How to check the solution

For example, we must decide if our user should be shown the Shipments screen. We call the goShipments function. The function analyzes giving object (context) and returns false if one the the rules didn't pass or the name of the screen user should be redirected to.

Running the code

  1. Press the Play button
  2. At console call the function goShipments(). It should return false value.
  3. Call goShipments({ hasShipments: true }). Now it returns the name of the screen Shipments.