my task:
‘‘It’s the academic year’s end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average for them. Easy ! You just need to write a script.
Return the average of the given array rounded down to its nearest integer.
The array will never be empty.’’
my code:
function getAverage(marks){
//TODO : calculate the downwar rounded average of the marks array
var sumMarks = 0;
for (var i=0; i==marks.lenghth-1; i++){
sumMarks+=marks[i];
}
var average = sumMarks / marks.length;
return Math.floor(average);
}
function getAverage(marks){
//TODO : calculate the downwar rounded average of the marks array
var sumMarks = 0;
for (var i=0; i===marks.lenghth-1; i++){
sumMarks+=marks[i];
}
var average = sumMarks / marks.length;
return Math.floor(average);
}
}
The average of 1,2,15,15,17,11,12,17,17,14,13,15,6,11,8,7 should return - Expected: 11, instead got: 0
function getAverage(marks){
//TODO : calculate the downwar rounded average of the marks array
var sumMarks = 0;
for (var i=0; i===marks.length-1; i++){
sumMarks+=marks[i];
}
var average = sumMarks / marks.length;
return Math.floor(average);
}