Javascripts Function - Syntax - Example
by Ranganathan[ Edit ] 2012-08-28 23:21:44
javascripts function:
syntax:
function functionName(parameter_1, parameter_2, .. parameter_n){
statement1
statement2
statementn
}
Example:
'<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT Language="JavaScript">
<!--
function getMax(n1, n2){
if (n1 < n2)
return n2
else
return n1
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT Language="JavaScript">
<!--
document.write("<P>")
document.write("The largest number of 5 or 6 is: " + getMax(5, 6))
document.write("</P>")
// -->
</SCRIPT>
</BODY>
</HTML>'