Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

What haven’t I done right: here is my code: function studentMsg(totalScores, studentScore) {
const passed = hasPassingGrade();
const passMsg = passed ? “You passed the cours.” :“You failed the course.”;
return ‘"’+“Class average: " + (getAverage(totalScores)+”.“+” Your grade: " + getGrade(studentScore) + “. " +passMsg)+'”';
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

Your code so far

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";
  }
}

function hasPassingGrade(score) {
  return getGrade(score) !== "F";
}


// User Editable Region

function studentMsg(totalScores, studentScore) {
const passed = hasPassingGrade();
const passMsg = passed ?  "You passed the cours." :"You failed the course.";
 return  '"'+"Class average: " +  (getAverage(totalScores)+"."+" Your grade: " + getGrade(studentScore) + ". " +passMsg)+'"';
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

// User Editable Region


Your browser information:

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

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

What do you want this line to do?

Please keep in mind that hasPassingGrade() is a function that takes an argument.

Tell us what’s happening:

for some reason I have been refused to pass, my code is working very well from what I am seeing in the console.

Your code so far

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";
  }
}

function hasPassingGrade(score) {
  return getGrade(score) !== "F";
}


// User Editable Region

function studentMsg(totalScores, studentScore) {
const passed = hasPassingGrade(studentScore);
const passMsg = passed ?  "You passed the cours." :"You failed the course.";
 return  '"'+"Class average: " +  (getAverage(totalScores)+"."+ " Your grade: " + getGrade(studentScore) + ". " +passMsg)+'"';
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37)); console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));

// User Editable Region


Your browser information:

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

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Check for typos

Thanks for the correction, but still wouldn’t pass me.

Why is that first sting there?

its for building the message to display exactly as they want it to display. you can as well run my code and see how smooth it works, but still wouldn’t pass me, been stock here. here is the code again:

function studentMsg(totalScores, studentScore) {
const passed = hasPassingGrade(studentScore);
const passMsg = passed ?  "You passed the course." :"You failed the course.";
 return  '"'+"Class average: " +  (getAverage(totalScores)+"."+ " Your grade: " + getGrade(studentScore) + ". " +passMsg)+'"';
}

I would double check that assumption, I don’t think it’s correct

but it is, kindly log the code and check, it works

Kindly try it since I have passed this step before.

‘My code cannot be wrong’ is usually an unfruitful approach to debugging. I’m trying to point out where the issue is without writing the answer for you (which is against the rules).

Oh ok, i thought you are here to help. thanks anyways for your time.

I am here to help. Helping is different than writing the answer for you.

Like I said above, I would double check your assumption that you are supposed to.ut quotation marks inside of your string.

1 Like