Review-js-fundamentals-by-building-a-gradebook-app/step-2

Hi im refreshing my Js skills,

Why is my solution wrong when in fact it returns the right scores.

So my logic was to use minimal code, and the least logical operators as possible so my understanding of js else if statements that if the block doesn’t execute it moves on. so i started with the smallest number first using <= to.

As you can see for the scores of 96, 82, 56 it returned the right grades A, B and F.

But the console is still giving me an error of if 78 it should have given a C mark but there is no input of 78 and if there was it would have gave the right marking.

Please post your actual code instead of a picture. Also, please post a link to the step. Thanks


You have a typo.

1 Like
function getGrade(score) {

  if(score <= 59){

    return "F";

  } else if (score <= 69){

    return "D";

  } else if (score <= 79){

    return "c";

  } else if (score <= 89){

    return "B";

  } else if (score <= 99){

    return "A"

  } else {

    return "A++";

  }

}

Review JavaScript Fundamentals by Building a Gradebook App: Step 2 | freeCodeCamp.org

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Will keep it in mind for next time, please bare with me.

As this is my first time using the forums.

Ps thanks a lot i totally skipped the lower case “c”

1 Like