Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

in the console the function sends me the rigth value but on the tests it shows up as wrong

Your code so far

function getAverage (array){
  let avg=0;
  for(let testScore of array){
  avg+=testScore
  }
  return avg/array.length
}
function getGrade (studentScore){
  if(studentScore==100){
    return "A+"
  }else if(90<=studentScore){
    return "A"
  }else if(80<=studentScore){
    return "B"  
  }else if(70<=studentScore){
    return "C"
  }else if(60<=studentScore){
    return "D"
  }else{ 
    return "F"
  }
    
}
function hasPassingGrade  (studentScore){
  return studentScore!=="F"?true:false
    
}
function studentMsg(arrayOfScores,studentScore){
let avg=getAverage(arrayOfScores)
let hasPassed=hasPassingGrade(getGrade(studentScore))
if(hasPassed){
  return `Class average: ${avg}. Your grade: ${getGrade}. You passed the course.`
}else{`Class average: ${avg}. Your grade: ${getGrade}. You failed the course.`}




}

console.log(hasPassingGrade("F"))
console.log(typeof hasPassingGrade("F")) 

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
https://www.freecodecamp.org/learn/full-stack-developer/lab-gradebook-app/build-a-gradebook-app

hi there,

you have a few problems that will need to be fixed to pass this challenge.

To start with, please re-read this instruction and compare what you wrote with what it is asking for:

The hasPassingGrade function should use the getGrade function to get the letter grade, and use it to determine if the grade is passing

The question to ask yourself after reading is. What type of value does hasPassingGrade expect? (a string? a number?)

1 Like

thanks for ht help i didnt read it correctly, it is passing a number i need to use the function to convert it to a letter grade, it was givving always true because a number is always difrent than F, thanks for the help

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.