Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

function hasPassingGrade(grade) {
if (grade === “F”) {
return false;
} else {
return true;
}
}
doesn’t this return false for “F”? The instructions say that it doesn’t, but I can’t see why.

Your code so far

function getAverage(arr) {
  let sum = 0;
  for (const comp of arr) {
    sum += comp
  }
  return (sum / arr.length)
}

function getGrade(num) {
  if (num === 100) {
    return "A+"
  } else if (90 <= num && num <= 99) {
    return "A";
  } else if (80 <= num && num <= 89) {
    return "B";
  } else if (70 <= num && num <= 79) {
    return "C";
  } else if (60 <= num && num <= 69) {
    return "D";
  } else {
    return "F";
  }
}

function hasPassingGrade(grade) {
  if (grade === "F") {
    return false;
  } else {
    return true;
  }
}

function studentMsg(arr, score) {
  const avg = getAverage(arr);
  const grade = getGrade(score)
  if (hasPassingGrade(grade)) {
    return `Class average: ${avg}. Your grade: ${grade}. You passed the course.`
  } else {
    return `Class average: ${avg}. Your grade: ${grade}. You failed the course.`
  }
}

console.log(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]))
console.log(getGrade(37))
console.log(hasPassingGrade("F"))
console.log(studentMsg([15, 25, 35, 45, 55, 60, 70, 60], 75))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Gradebook App - Build a Gradebook App

you need to check again what hasPassingGrade receives as an argument

1 Like