Command Shift

Keeping Fit - ;TLDR

As our pets get older, they now become less fit. To counteract this, we want to be able to give them some exercise to boost their fitness levels.

Your challenge in this step is to give the Pet function a walk method that increases it's fitness level.

  • calling walk should increase the Pet's fitness level by 4

  • A pet's fitness level should never go above 10, so if the fitness level is 9, walk should increase fitness to 10

Learning objectives

  • understanding what state is

  • understanding what refactoring is

  • understanding what a magic number is

To complete this challenge, you will need to:

  • test the expected behaviour in the Node CLI

  • write unit tests to to cover the expected behaviour

  • implement the code to make the tests pass

  • refactor your code to remove magic numbers

Once you are done, commit your work and push to GitHub

On this page