Tell us what’s happening:
I got stucked on step 3 hasPassingGrade function
and 4 studentMsg function
on how to access the result of the other functions in the student function
. I even tried rewriting all the other functions into the studentMsg
own which didn’t work. I checked the hint section and i was able to solve but still don’t fully understand it. i would like to ask if there are any resources available to learn more about this approach
Your code so far
function getAverage(testScore){
let totalScore = 0
for(let score of testScore){
totalScore+= score
}
return totalScore / testScore.length
}
function getGrade(score){
let result;
switch(true){
case (score === 100):
result = `A+`;
break;
case (score >= 90 && score <= 99):
result = "A";
break;
case (score >= 80 && score <= 89):
result = "B";
break;
case (score >= 70 && score <= 79):
result = `C`;
break;
case (score >= 60 && score <= 69):
result = `D`;
break;
default:
result = `F`;
break;
}
return result
}
function hasPassingGrade(passingGrade){
if(getGrade(passingGrade) === `F`){
return false
}else{
return true
}
}
function studentMsg(arrayOfScores,studentScore){
if(hasPassingGrade(studentScore) === false){
return `Class average: ${getAverage(arrayOfScores)}. Your grade: ${getGrade(studentScore)}. You failed the course.`
}else{
return `Class average: ${getAverage(arrayOfScores)}. Your grade: ${getGrade(studentScore)}. You passed the course.`}
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89],37))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App