var total = 0; for(var i = 0; i < grades.length; i++) { total += grades[i]; } var avg = total / grades.length;