Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Return value from a function in 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);
}