You can create a function in JavaScript and add arguments to it. An argument is one or more variables that are declared within the parenthesis of a function definition. The syntax is
function MyFunction(x,y,z)
{ statements;}
You can also use the return keyword to return a value to the statement.
function MyFunction(x,y,z)
{ return value; }
Example:
function Area_Rect(width,length)
{ area=width*length;
return area;}
You can call the function by assigning values to the arguments, such as
document.write(Area_Rect(4,6));
0r alert (“The area of a rectangle is”+Area_Rect(4,6)
The area of the rectangle if width=4 and length=6 is:
Please follow Lesson 13 and Lesson 14 to learn more about function.