Back to Freecodecamp

Step 2

curriculum/challenges/english/blocks/review-js-fundamentals-by-building-a-gradebook-app/6626a060c4006f793e10cb33.md

latest2.2 KB
Original Source

--description--

Now the teacher needs your help converting the student score to a letter grade.

Complete the getGrade function that takes a number score as a parameter. Your function should return a string representing a letter grade based on the score.

Here are the scores and their corresponding letter grades:

Score RangeGrade
100"A++"
90 - 99"A"
80 - 89"B"
70 - 79"C"
60 - 69"D"
0 - 59"F"

Tips

  • Remember that you learned about conditional statements (if, else if, and else).
  • Remember that you learned about comparison operators (>, <, >=, <=, ===).
  • Remember that you learned about the logical AND operator (&&).

--hints--

Your getGrade function should return "A++" if the score is 100.

js
assert.strictEqual(getGrade(100), "A++");

Your getGrade function should return "A" if the score is 94.

js
assert.strictEqual(getGrade(94), "A");

Your getGrade function should return "B" if the score is between 80 and 89.

js
assert.strictEqual(getGrade(80), "B");
assert.strictEqual(getGrade(83), "B");
assert.strictEqual(getGrade(88), "B");

Your getGrade function should return "C" if the score is 78.

js
assert.strictEqual(getGrade(75), "C");

Your getGrade function should return "D" if the score is between 60 and 69.

js
assert.strictEqual(getGrade(60), "D");
assert.strictEqual(getGrade(63), "D");
assert.strictEqual(getGrade(68), "D");

Your getGrade function should return "F" if the score is 57.

js
assert.strictEqual(getGrade(57), "F");

Your getGrade function should return "F" if the score is between 0 and 59.

js
assert.strictEqual(getGrade(0), "F");
assert.strictEqual(getGrade(30), "F");
assert.strictEqual(getGrade(43), "F");

--seed--

--seed-contents--

js
function getAverage(scores) {
  let sum = 0;

  for (const score of scores) {
    sum += score;
  }

  return sum / scores.length;
}
--fcc-editable-region--
function getGrade(score) {

}

console.log(getGrade(96));
console.log(getGrade(82));
console.log(getGrade(56));
--fcc-editable-region--