Back to Freecodecamp

Step 3

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

latest1.8 KB
Original Source

--description--

The teacher is really happy with the program you have created so far. But now they want to have an easy way to check if a student has a passing grade. A passing grade is anything that is not an "F".

Complete the function hasPassingGrade that takes a student score as a parameter. Your function should return true if the student has a passing grade and false if they do not.

Tips

  • Use the getGrade function to get the student's grade. Then check if the grade is passing or not.

--hints--

Your hasPassingGrade function should return a boolean value.

js
assert.strictEqual(typeof hasPassingGrade(100), "boolean");

Your hasPassingGrade function should return true if the grade is an "A".

js
assert.isTrue(hasPassingGrade(100));

Your hasPassingGrade function should return false if the grade is an "F".

js
assert.isFalse(hasPassingGrade(53));

Your hasPassingGrade function should return true for all passing grades.

js
assert.isTrue(hasPassingGrade(87));
assert.isTrue(hasPassingGrade(60));
assert.isTrue(hasPassingGrade(73));
assert.isTrue(hasPassingGrade(96));

--seed--

--seed-contents--

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

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

  return sum / scores.length;
}

function getGrade(score) {
  if (score === 100) {
    return "A++";
  } else if (score >= 90) {
    return "A";
  } else if (score >= 80) {
    return "B";
  } else if (score >= 70) {
    return "C";
  } else if (score >= 60) {
    return "D";
  } else {
    return "F";
  }
}

--fcc-editable-region--
function hasPassingGrade(score) {
  
}


console.log(hasPassingGrade(100));
console.log(hasPassingGrade(53));
console.log(hasPassingGrade(87));
--fcc-editable-region--