Tell us what’s happening:
cant pass this no. 26
Your studentMsg function should return the correct message based on the student’s score and the class average.
can you give me a hint what I did wrong, thank you so much
Your code so far
function getAverage(arr){
let sum = 0;
for(let i = 0; i < arr.length; i++){
sum += arr[i];
}
return sum/arr.length;
}
function getGrade(num){
let result = "";
if(num == 100){
result = "A+"
}else if(num >= 90 && num <=99){
result = "A"
}else if(num >= 80 && num <=89){
result = "B"
}else if(num >= 70 && num <=79){
result = "C"
}else if(num >= 60 && num <=69){
result = "D"
}else{
result = "F"
}
return result;
}
function hasPassingGrade(score){
let grade = getGrade(score)
if(grade == "F"){
return false;
}else{
return true;
}
}
function studentMsg(arr,score){
const studentAve = getAverage(arr);
const studentGrade = getGrade(score);
let msg = "";
if(hasPassingGrade(score) === true){
msg = console.log(`Class average: ${studentAve}. Your grade: ${studentGrade}. You passed the course.`);
}else{
msg = console.log(`Class average: ${studentAve}. Your grade: ${studentGrade}. You failed the course.`);
}
return msg;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Challenge Information:
Build a Gradebook App - Build a Gradebook App