the example code from the book Professional JavaScript for Web Developers, 2nd Edition