Now if you’re into functional programming or just like a compact one-liner:
const avg = grades.reduce((sum, grade) => sum + grade, 0) / grades.length;
console.log(avg);
This method uses .reduce() to total up all values in one go.
It’s elegant, efficient, and very “modern JavaScript.” Perfect for when you want that JavaScript average without writing multiple lines.