Head First JavaScript Code: Chapter 6, Functions

Chapter 6 Opening Image

If there was an environmental movement within JavaScript, it would be led by functions.

Head First JavaScript

Functions allow you to make JavaScript code more efficient, and yes, more reusable. Functions are also task-oriented, good at code organization, and excellent problem solvers. Sounds like the makings of a good resume! In reality, all but the simplest of scripts stand to benefit from a functional reorganization. While it's hard to put a number on the carbon footprint of the average function, let's just say they do their part in making scripts as eco-friendly as possible.

Download the Code

Code Description and Viewing

Mandango

The Mandango web page from Chapter 5 is continued here, and is built incrementally throughout the chapter. Each numbered HTML file corresponds to an incremental version of the web page. When a page number appears beside a file, it is either the page where the file's contents are presented or the exercise (solution) corresponding to the file.

  • mandango6.html - Mandango web page with a new function for handling seat setting (page 259)
  • mandango7.html - Mandango web page with a new function that gets the status of a seat (page 268)
  • mandango8.html - Mandango web page with separation of code thanks to function reference event handlers (page 282)
  • seat_select.png - Selected movie seat image that appears on the Mandango web page
  • seat_avail.png - Available movie seat image that appears on the Mandango web page
  • seat_unavail.png - Unavailable movie seat image that appears on the Mandango web page