Grade Calculator

Write a function named calculateGrade that takes one parameter: score, which is a number representing a student's score. The function should return the grade based on the following criteria:

  • If the score is 90 or above, return "A"

  • If the score is 80 or above but less than 90, return "B"

  • If the score is 70 or above but less than 80, return "C"

  • If the score is 60 or above but less than 70, return "D"

  • If the score is below 60, return "F" ​

Example 1

Input: calculateGrade(85);
Output: "B"

Example 2

Input: calculateGrade(95);
Output: "A"

Example 3

Input: calculateGrade(58);
Output: "F"

Are you stuck on this problem?

Get detailed, step-by-step solution and improve your JavaScript skills.

  • Detailed Explanation: Each solution comes with a comprehensive explanation, helping you understand the logic and concepts thoroughly.
  • Learn to Write Better Code: Even if you have written the code, discover ways to improve it and adopt best practices.
  • Save Time: Don’t waste hours struggling—get the solution and learn efficiently.
  • Lifetime Access: Get access to lifetime solutions for all problems available
Get the Solution

" I struggled with this problem for hours, but the solution provided here was clear and easy to follow. It helped me understand where I went wrong and improved my coding skills significantly." - Jane D.

If you're not satisfied, I offer a 7-day money-back guarantee.