Refactor lesson 4

Add a refactored version of lesson 4 as well as
an HTML document that runs it.