Hi,
Im trying to make a calculator that on click displays the sum of the data in the array and provides the mean/ average.

I have the formula for the mean = number of items(array.length?) * sum of array.

Please help:confused:

Can anyone recommend a superb/afordable/online javascript course?

<html>
<head>
<title>Aggregates</title>

<script type="text/javascript">
var array = new Array();
function insert(val)
{
array[array.length]=val;
}
function show()
{
var string="";
for(i = 0; i < array.length; i++)
document.getElementById("e").value = string =string+array[i]+"\

";

}
function sum(array)
{ numberTotal = 0
for (var total = 0; total < array.length; total = total + 1)
numberTotal = numberTotal + numberArray[total]
return numberTotal
document.getElementById("sum").value = numberTotal.value;
}
</script>

</head>

<body>
<h1>Aggregates</h1>

<h3>Add as many numbers as you like </br> to the list, then click Calculate.</h3>
<form id="form">
<input type="text" name="name" value="">
<input type="button" value="Add to list" onClick="insert(this.form.name.value),show();"></br>
<textarea name="txt" id="e" rows="10" ></textarea> </br>
<h4>Total (Sum):</h4>
<input type="text" id="Sum" value="0"></br>
<input type="button" value="Calculate" onClick="sum(array);"></input>
<h4>Average:</h4>
<input type="text" id="answer" value="0"></br>
<input type="button" value="Reset" onClick="form.reset();" />
</form>

It applies to all references of that array variable.

Youāll find that itās not the only problem in the code. There are lots of problems that prevent it from working, but we can work through them steadily, understanding and solving the issues at hand.

:DThanks so much! I been going crazy with this, I really appreciate your help

Ive rename the array to numbers for clarity and reference as suggested, This (val) part in blue-Is it correct/necessary?

var numbers = new Array();

function insert(val)
{
array[numbers.length]=val;
}
function show()
{
var string="";
for(i = 0; i < array.length; i++)
document.getElementById("e").value = string=string+array[i]+"\

Now large amounts of learning wonāt be achieved by that person, as we go through the details of what causes the problems and the aspects around them that lead to useful solutions.

Itās obvious he/she isnāt (interested in?) learning anythingā¦ itās been 24 hours, and he/she is still dilly-dalying with variable namesā¦ itās obvious he/she just wants someone to do his/her (home?) work for him/her.

Iām not one to force someone to learn if they donāt want toā¦ if it is, indeed, homework, youāre only cheating yourself I sayā¦ if itās something elseā¦ well maybe learning javascript isnāt a priority in his/her lifeā¦

PS - If Iāve robbed someone of the opportunity to learn, I apologizeā¦ if you want a free, good resource for learning Javascript interactively, and at your own pace, try W3Schools Online Web Tutorials - cheers.

Please do not use w3schools, as large parts of their material is out of date or incorrect. I donāt say that lightly. Here is a long list of JavaScript w3schools corrections

A more acurate place to learn about JavaScript is from places like Eloquent JavaScript