Pass number to a function : Function Parameters : Function JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Function » Function Parameters »

 

Pass number to a function

















<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
function calcAvg()
{
    var inpNum1 = 1;
    var inpNum2 = 2;
    var inpNum3 = 3;
    var inpNum4 = 4;
    numAvg = doCalcAvg(inpNum1, inpNum2, inpNum3, inpNum4);
    document.write("The average of the four numbers you entered is: " + numAvg);
}

function doCalcAvg(inpNum1, inpNum2, inpNum3, inpNum4)
{
    var ans;
    ans = (Number(inpNum1+ Number(inpNum2+ Number(inpNum3+ Number(inpNum4)) 4;
    return (ans);
}
//  -->
</script>
</head>
<body onLoad="calcAvg();">
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Function
» Function Parameters