PDA

View Full Version : Need help with the average number



liffland
04-25-2005, 03:16 PM
<html>
<head>
<title>Get Average</title>


<script type="text/javascript">

function getAvg(num1, num2, num3){
var average=arguments[num1, num2, num3]
for (i=0; i<arguments.length; i++){
var sum=num1+num2+num3
average= parseFloat(sum/3.0)
}
return(average)
}

</script>


</head>
<body>
<h2>Get Average Number</h2>


<script language="JavaScript" type="text/javascript"><!--
var num1=prompt("Enter a number: ", "")
var num2=prompt("Enter another number: ", "")
var num3=prompt("Enter the third number: ", "")
var avg= getAvg(num1, num2, num3)
document.write("You entered: ", num1, ", ", num2, ", ", num3, ", and the Average is: ", avg)

// -->
</script>

</body>
</html>