January 2001
Beginner
312 pages
6h 4m
English
One statement you didn't look at in the previous chapter is the return statement. (Well, in fact there is one other—the with statement—but you'll come across that in the next chapter!)
The return statement was omitted from the previous chapter because it deals specifically with functions and at that time, you hadn't discovered functions. So, let's take a look at it now.
You've seen how parameters can be used to pass data from a referring function to a receiving function so that it can work on the data; well, there is a way to pass the result back. This is done with the return statement:
<html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- Cloaking device on! function calcAvg() { var inpNum1 = prompt("Enter ...Read now
Unlock full access