<script src="http://wilderland.org/javascript2/findAverageTest.js"></script>
<div class='explanation'>
The tests in this fiddle expect a function called "findAverage". The tests will pass the function an array of numbers. The function should return the average of all the values in the array.
<p>
Recall that the <i>average</i> of a set of numbers is the sum of the numbers divided by how many there are. So, the average of <code>[ 1, 3, 5 ]</code> is 3, because <code>1 + 3 + 5</code> is 9, and 9 divided by 3 is 3.
</div>
<button>Click To Run Tests</button>
<div id=results></div>
function findAverage(list) {
var i, current, sum = 0;
for (var i = 0; i < list.length; ++i) {
current = list[i]; //finds numbers in list form
sum = sum+current; //appends current number to array
//sums array, needs work
}
return sum/list.length;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.