Tell us what’s happening:
i succeed passed all tests except number 19 test ? i dunno why although i tested the function manually on the console and i got the right result ?!
- Your
hasPassingGradefunction should returnfalseif the grade is an"F". <<
Your code so far
function getAverage(scores) {
let totalScore = 0
for(const score of scores) {
totalScore += score
}
return totalScore / scores.length
}
function getGrade(score) {
let mark = ''
if(score == 100) {
mark = 'A+'
}
if(score > 89 && score < 100) {
mark = 'A'
}
if(score > 79 && score < 90) {
mark = 'B'
}
if(score > 69 && score < 80) {
mark = 'C'
}
if(score > 59 && score < 70) {
mark = 'D'
}
if(score >= 0 && score < 60) {
mark = 'F'
}
return mark
}
function hasPassingGrade(grade) {
if(grade == 'F') {
return false
} else {
return true
}
}
function studentMsg(arrOfScores, studentScore) {
return `Class average: ${getAverage(arrOfScores)}. Your grade: ${getGrade(studentScore)}. ${hasPassingGrade(getGrade(studentScore)) ? 'You passed the course': 'You failed the course'}.`}
console.log(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]))
console.log(getAverage([10, 20, 30, 40, 50, 60, 70, 97]))
console.log(getGrade(getAverage([10, 20, 30, 40, 55, 65, 75, 83])))
console.log(hasPassingGrade(getGrade(getAverage([10, 20, 30, 40, 55, 65, 75, 83]))))
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37))
console.log(hasPassingGrade(getGrade(getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]))))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App
https://www.freecodecamp.org/learn/full-stack-developer/lab-gradebook-app/build-a-gradebook-app