⭐ BONUS EXERCISE

EXERCISE 7: Grade Calculator with Arrays and Functions

Assignment

Create a grade calculator program that:

  1. Creates an array of at least 5 student names
  2. Creates a corresponding array of their grades (numbers between 0-100)
  3. Creates a function called getLetterGrade that:
    • Takes a numeric grade as parameter
    • Returns a letter grade based on:
      • A: 90-100
      • B: 80-89
      • C: 70-79
      • D: 60-69
      • F: below 60
  4. Creates a function called calculateClassAverage that:
    • Takes an array of grades as parameter
    • Returns the average of all grades
  5. Uses a for loop to display each student's name, numeric grade, and letter grade
  6. Displays the class average at the end
  7. Uses filter to find and display only students who passed (grade >= 60)

Requirements:

  • Use arrays for storing student names and grades
  • Use functions with parameters and return values
  • Use for loops, filter, and template literals
  • Use an external JavaScript file (script.js) linked to your HTML
  • Display results using both console.log() and document.write()

Create an index.html file and a script.js file with your solution.