First draft

Actually it's more of a first draft of a first draft. I'll keep updating the pull request until there's a proper first draft. The beginning, in particular, is quite choppy and decrepit. The middle isn't that great either. But the end is pretty good... right up until you fall off the page. 
Hmmm, good idea. That's going to lead in to a discussion of functional vs OO styles, and how they can both be used in JS but sometimes one is better than the other, which then leads into a classic holy war. Which I will now win decisively once and for all.