It’s claiming the first “else if” is an unexpected token. I don’t know what that means or what i’m doing wrong. Other forums aren’t helping. Google isn’t helping.
Your code so far
function getAverage(scores) {
let sum = 0;
for (const score of scores) {
sum += score;
}
return sum / scores.length;
}
// User Editable Region
function getGrade(score) {
if (score == 100) {
return "A++";
} else if (score >= 90 && <= 99) {
return "A";
} else if (score >= 80 && <= 89) {
return "B";
} else if (score >= 70 && <= 79) {
return "C";
} else if (score >= 60 && <= 69) {
return "D";
} else {
return "F";
}
}
console.log(getGrade(96));
console.log(getGrade(82));
console.log(getGrade(56));
// 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 2
edit: so while I got the error fixed after reading it, I don’t actually get why it was an error. I told it “greater than or equal to 90, or less than or equal to 99.” I don’t get why that would have been an error to begin with.
what confuses me there is that I did have the >= on the left, and I didn’t need it on both sides- the code passed after I removed the one on the right entirely. The passing code didn’t have a <= at all.
Ultimately the code passed, i’m just annoyed that it was something so simple- something I don’t actually understand at all, lol.
Even still, it doesn’t explain why it was telling me “else if” was wrong before. It’s doing it again on the next lesson, it’s just saying that “else if” needs to be removed.