Appendix A. ANSWERS TO ASSIGNMENTS

Here are solutions to the assignments I've given at the end of each chapter. The scripts and images used in the solutions may be found on this book's companion website (http://www.bookofjavascript.com). The JavaScript in this appendix contains comments where I think explanation is necessary. If your solution works and is not much longer than mine, you've done a good job. There is no assignment for Chapter 17, so we'll start with Chapter 2.

The Chapter 2 assignment asks you to change Figure 2-12 so that seconds are displayed along with minutes and hours. Use the Date object's getSeconds() method to get the number of seconds and the fixTime() function to fix the formatting of the seconds.

<html> <head> <title>Chapter ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.