Need help understanding why this would not work in the finalGrade() challenge

finalGrade() challenge

Just finished the finalGrade() challenge and the below code was the first I tried before finding the solution:

const finalGrade = (grade1, grade2, grade3) => {
let grade = (grade1 + grade2 + grade3) / 3;
if (grade >= 0 && grade <= 59) {
return 'F';
} else if (grade >= 60 && grade <= 69) {
return 'D';
} else if (grade >=70 && grade <= 79) {
return 'C';
} else if (grade >= 80 && grade <=89) {
return 'B';
} else if (grade >= 90 && grade <= 100) {
return 'A';
} else if ((grade1 || grade2 || grade3) < 0 || (grade1 || grade2 || grade3) > 100) {
return 'You have entered an invalid grade.';
}
}

I also tried just writing

else {
return 'You have entered an invalid grade.';
}

Program seemed to run correctly with this but it was not the solution codecademy was looking for.

But now I am curious as to the reason why exactly my initial solution didn’t work? Or maybe it just wasn’t how Codecademy intended it be solved? TIA!

I would generally advise to do validation first, given having valid data to work with is easier

well, if we had this function call:

console.log(finalGrade(105, -5, 50)) 

both 105 an -5 are not valid grades. Yet your function gives F grade, instead of the message to inform that I have entered an invalid grade

Okay great. I will keep that in mind in the future. thanks so much for your help!