April 21, 2009

0 The return statement in JavaScript

The return statement is used to specify the value that is returned from the function.

So, functions that are going to return a value must use the return statement.


The function below should return the product of two nos (a and b).

function prod(a, b)
return x

When u call the function above, you must pass along two parameteres:

product=prod (2, 3)

The return value from the prod() function is 6, and it will be stored in the variable called product.


<script type="text/javascript">
function displaymessage ( )
alert ("Hello World")
<input type="button" value="Click me!" onClick="displaymessage ()">


Post a Comment

Blogger Themes

Powered by Blogger