December 2001
Intermediate to advanced
480 pages
9h 22m
English
Creating a function involves stating a function name and then adding a series of statements or other functions between curly braces. The general format is as follows:
function functionName(optional arguments) {
statements or other functions
} For example, the following function in the following script can be used to determine the number of 1 × 8 boards needed for a shed’s walls. The two arguments in the function, front and side, are used as variables in two prompt functions.
<html>
<head>
<title>Shed Planner</title>
<script language="JavaScript">
function shedWalls(front,side) { var front=prompt("How many feet across the front?",""); var side=prompt("How many feet along the side?",""); var numFront=(front * 12 * 2)/8; var ...Read now
Unlock full access