Created
February 10, 2012 20:05
-
-
Save jbfink/1792359 to your computer and use it in GitHub Desktop.
codeyear week5, timetrials 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// runner times | |
var carlos = [9.6,10.6,11.2,10.3,11.5]; | |
var sarah = [10.6,11.2,9.4,12.3,10.1]; | |
var timothy = [12.2,11.8,12.5,10.9,11.1]; | |
var calculateAverage = function (raceTimes) { | |
var totalTime; | |
for ( i = 0; i < raceTimes.length; i++ ) { | |
totalTime = (totalTime || 0) + raceTimes[i]; | |
// assign variable averageTime | |
} | |
var averageTime = totalTime / raceTimes.length; | |
return averageTime; | |
}; | |
// write the result of your function call console.log() | |
console.log(calculateAverage(timothy)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment