calculating the average/mean
Hi,
Im trying to calculate the mean/average of numbers in an array any suggestions with the mean() would be very much appreciated.:)
how can i get the length of an array to perform in a simple / maths problem whilst being flexiable to the length of the array?:crazy:
function sum()
{
var i=0
for (i=0, total=0;i <numbers.length; i++)
{
total += numbers[i];
}
document.getElementById("txtTotal").value = total;
}
function mean()
{
document.getElementById("answer") = parseFloat(document.getElementById("txtTotal").value) / parseFloat(numbers.length);
}