the example code from the book Professional JavaScript for Web Developers, 3rd Edition