I am trying to solve a question such that if someone scores a score between 0 and 5, he/she has a grade of F, if they have a score above 5 and below or equal to 10 they have E and so on. I have written my answers but I don't know I am getting undefined on the next.
Question Image:
My Answer:
function getGrade(score) {
let grade;
// Write your code here
if (score >= 0 && score <=5) {
console.log("F");
}
else if (score > 5 && score <=10) {
console.log("E");
}
else if (score > 10 && score <=15) {
console.log("D");
}
else if (score > 15 && score <=20) {
console.log("C");
}
else if (score > 20 && score <=25) {
console.log("B");
}
else if (score > 25 && score <=30) {
console.log("A");
}
return grade;
}
getGrade(11)
Aucun commentaire:
Enregistrer un commentaire