Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 3, 2012

Codecademy: Codeyear Calculating totals with a function


//sample solution

// runner times
var carlos = [9.6,10.6,11.2,10.3,11.5];
var liu = [10.6,11.2,9.4,12.3,10.1];
var timothy = [12.2,11.8,12.5,10.9,11.1];

// declare your function calculateTotal here
var calculateTotal= function(raceTimes){
var totalTime = 0;
for(var i=0;i<raceTimes.length;i++){
totalTime = totalTime + raceTimes[i];
}
return totalTime;
};

var liuTotal = calculateTotal(liu);

console.log(liuTotal);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts