Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

This stage seems so confusing for me and i do not understand why my code is not passing through. i am exhausted and i need help!

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) {
let classAverage = getAverage;
let studentGrade = getGrade;

if (getGrade){
  return "Class average:  totalScore + studentScore: grade-goes-here.  You passed the course."
} else {
  return "Class avearge:  totalScore + studentScore: grade-goes-here.  You failed the course."
}
}
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/125.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Ok, let’s break this down.

Firstly, you need to pass arguments to the function parameters if you want to calculate the average score or the student’s grade.

let classAverage = getAverage;
let studentGrade = getGrade;

Next, your conditional statement should be checking whether or not the student has a passing grade or not. The getGrade function is not the correct function for this.

if (getGrade) {

Finally, your function should return the correct string value (with the relevant variables interpolated).
To interpolate variables, they need to be outside of the quote marks (e.g. "String" + variable + "string").
You also need to ensure that spacing, capitalisation, punctuation, spelling etc exactly match the required string.

"Class average:  totalScore + studentScore: grade-goes-here.  You passed the course."

Start by putting this at the bottom of your code so you can see what should be being returned by your console.log():

// expected output
console.log("Class average: 71.7. Your grade: F. You failed the course.")

//i am getting right o/p still it’s not passing. don’t know why?
– code removed

In the future, please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.

The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.

Thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.