# Building a gradebook app step 2

heres my code but it wont pass

``````function getGrade(score) {
return 'A++'
} else if (getGrade =< 99)
return 'A'
} else if (getGrade =< 89)
return 'B'
} else if (getGrade =< 79)
return 'C'
} else if (getGrade =< 69)
return 'D'
} else 'F'

``````

i dont know anything about debugging

Have you tried anything to figure out what might be wrong? Thatâs called âdebuggingâ

no someone told me not to use chat gpt which is the only thing that helps me with the mistakes

well yeah i have went to other websites to see how to write the if else statements but the examples are different than the tutorial im doing

ChatGPT doesnât know how to code, so I wouldnât use that to help you write your code.

It looks like you are trying to write an if-else statement. Do you remember where youâve seen those before? How does your if-else statement look different than other examples?

i dont know the exact lesson it could take a few hours to look through them all again

I canât write the solution for you.

You said above you have looked at other examples of if-else statements. How does yours look different than those examples?

``````const distribution = {
A: 90,
B: 80,
C: 70,
D: 60,
F: 0
};

const getGrade = (score, distribution, maxScore = 100, minScore = 0) => {

// Handle edge cases
if (score > maxScore || score < minScore) {
return "Error";
}
// Get an array of the letter grades

// Sort the grades in descending order of the floor score of each grade
grades.sort((a, b) => distribution[b] - distribution[a]);

// Since the grades are sorted, the first grade to be lower than the score will be the correct grade to return

// No + or - for bottom grade
} else if (score - distribution[grade] <= 2) { // check and return "-" grades
} else if (score - distribution[grade] >= 8) { // check and return "+" grades
} else { // return normal grades
}
``````

///example 2

``````function myGrading (score) {

// Edge cases
if (score < 0 || score > 100) return 'INVALID SCORE';
if (score == 100) return 'A+';

// Important values
var decimal = score % 10;
score = Math.floor(score / 10); // <- here we reduce the range to 0-9

// 0    1    2    3    4    5    6    7    8    9
var scores = ['F', 'F', 'F', 'F', 'F', 'F', 'D', 'C', 'B', 'A'];

if (decimal <= 2) grade += '-';
else if (decimal >= 8) grade += '+';
}

}
``````

// example 3

``````const age = 12;

if (age >= 18) {
} else {
console.log("Nick is a child.");
}
``````

Can you talk about how your syntax looks different that the syntax in those examples?

(Note - I wouldnât look up examples of how to pass this exact exercise. That isnât the point of the âReviewâ courses. You are supposed to practice thinking up ways to approach problems.)

well my code starts with a function then it has a set of if else statements underneath it.

one of the other codes start with a variable and a list of scores underneath it. then it has another variable underneath it that says âscoreâ âdistrobutionâ âmax scoreâ 100, min score

btw is there a lesson online that teaches how to think up ways to approach problems since we dont have to remember syntax?

Iâd start comparing the basic parts of the syntax

How are these different?

const age = 12;

if (age >= 18) {
} else {
console.log(âNick is a child.â);
}

this code isnt written in a function mine is. this code does not provide a range of two numbers like 99-90

Go on, there are many differences. Focus on the syntax I quoted. You wrote your if statement differently than the example

i am using return theres no console log after each âif elseâ because they are already pre written at the bottom

Lets go even simpler. How are these lines different?

ones >= and the other is =