am currently learn a full-stack dev career path. So I’ve reached some series of quiz (about javascript functions)
and the quiz was :
-Write a function, finalGrade(). It should:
take three arguments of type number
find the average of those three numbers
return the letter grade (as a string) that the average corresponds to
return ‘You have entered an invalid grade.’ if any of the three grades are less than 0 or greater than 100
0-59 should return: ‘F’
60-69 should return: ‘D’
70-79 should return: ‘C’
80-89 should return: ‘B’
90-100 should return: ‘A’
my code’s
function finalGrade(grade1, grade2, grade3) {
if ((grade1 < 0 || grade1 >100) || (grade2 < 0 || grade2 > 100) || (grade3 < 0 || grade3 > 100)) {
return 'You have entered an invalid grade'
}
const sum = grade1 + grade2 + grade3;
const average = sum / 3;
if (average <= 59) {
return 'F'
} else if (average <= 69) {
return 'D'
} else if (average <= 79) {
return 'C'
} else if (average <= 89) {
return 'B'
} else {
return 'A'
}
}
but am stuck coz I didn’t use the same code as they expected me to… and am sure my code’s doing what they asked me to. so the question here is: Do I have to accept to copy their solution while I know I’ve not done any mistake?