1const avg = arr => {
2 const sum = arr.reduce((acc, cur) => acc + cur);
3 const average = sum/arr.length;
4 return average;
5}
6
7console.log(avg([1, 2, 3, 7, 8]));
1var total = 0;
2for(var i = 0; i < grades.length; i++) {
3 total += grades[i];
4}
5var avg = total / grades.length;
6