Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

Someone help what can be the problem here, I keep getting error message

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) {
  if (score >= 60) {
    console.log("Class average:" + getAverage(score) + "." + "Your grade:" + getGrade(score) + "." + "You passed the course.");
  }
  else {
    console.log("Class average:" + getAverage(score) + "." + "Your grade:" + getGrade(score) + "." + "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/124.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

double check your spacing, make sure to add all the necessary spaces

Tell us what’s happening:

Please someone help i’ve been stuck here for 2 hours trying to solve the issue, can someone tell me where the error is

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) {
  if (score >= 60) {
    console.log("Class average:" + getAverage(score) + "." + "Your grade:" + getGrade(score) + "." + "You passed the course.");
  }
  else {
    console.log("Class average:" + getAverage(score) + "." + "Your grade:" + getGrade(score) + "." + "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/124.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

try to write few lines of pseudo codes of what u plan to do? Can look at that Tips section

Hi @hibachenni22 !

Pay attention to the error messages you are getting in the console

the error message is this

ReferenceError: score is not defined

You haven’t defined score here.

so you can’t use it. Also remember that the function expects an array of scores. not just one score

you need to use the parameters they gave you here

pick the parameter that makes the most sense to use there and replace score

once you fix that, then you need to fix this issue here too

score is not defined there either

again, you need to use the parameters given to you here

that is what is available to you.

you have the same issue here

you can’t use score there either.

you need to use one of the parameters from the function here

make sure to test your code along the way.
that is why the console statement is there for you so you can see what is going on with your code

once you fix those issues, then you need to fix the spacing issues mentioned.

this is what your code prints currently

Class average:71.7.Your grade:F.You failed the course.

you have spacing issues you need to fix

lastly, the function says to return the string not print it

once you fix all of those things, then it will pass

hope that helps

3 posts were split to a new topic: Need help with step 4 of gradebook app project

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