Solution for Exercise 10.2

This is a solution for Exercise 10.2. See the source code for this file, and check the output in the console.