How to Calculate Average (Arithmetic Mean) To calculate the average of a group of numbers, all one must do is add all the numbers up and then divide by the total amount of numbers.

Let’s take the following numbers for example:

`6, 5, 4, 3`

The sigma of 1 through n – or the sum of all the numbers is 18.

`6 + 5 + 4 + 3 = 18`

The n – or the total count of numbers is 4.
18 divided by 4 is 4.5.

`18 / 4 = 4.5`

It’s easy. Here, you can try it yourself.
``` function calcAvg(){ var string = document.getElementById('numbers').value; var array = string.split(','); var sum = 0; for (index = 0; index < array.length; ++index) { var myx = parseFloat(array[index]); if(isNaN(myx )){ alert(myx + ' is not a number. Please enter comma separated numbers only.'); return false; } sum = sum + myx ; } var avrg = sum / array.length; var result = document.getElementById('result').value; var msg = ''; if(avrg == parseFloat(result) ){ msg = 'Correct!'; }else{ msg = 'Incorrect, the average is ' + avrg + '.'; } document.getElementById('answer').innerHTML = msg ; } Enter your comma separated numbers here: Enter your calculation result for the average here: ```

``` ```