Futurice logo

First programs aka writing recipes

Keywords

javascript, testing

understanding how software works and how to ensure the quality of the written software

Prime Target Group

advanced elementary school students

Required Equipment and Material

text editor, browser

Short Description

In this exercise kids will learn how to use existing libraries and how to ensure the quality of the code they write through basic unit testing.


Preparations

Open index.html in a browser and in a text editor. Look at the existing code in index.html and then try to modify it to complete the tasks below. You will need to modify the JavaScript.

Links that will help you complete the tasks are:


Tasks

  1. Fix the test that’s broken.
  2. Add a test for the packPresent function.
  3. Write a test to make sure that SantaClause does not try to deliver more presents than he has loaded. After writing the test and seeing it fail, change the code so it throws an error if he doesn’t have any more packages to deliver.
  4. Change the code of deliverPresents, so SantaClause packs enough presents before delivering them.
  5. Add another object Reindeer that has a function feed, which makes it more happy. Write an appropriate test before writing the code and check that the test passes when the code is written and the reindeer is happier indeed.

License

CC BY 4.0