Build a Gradebook App - Build a Gradebook App

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 ?!

  1. Your hasPassingGrade function should return false if 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

the instruction you need to re-read is this one

You should have a function named hasPassingGrade that takes a score as a parameter and returns either true or false

What type of input argument does hasPassingGrade expect?
(is it a string, a number, something else?)

so should i check for the type of the parameter

You should try to answer the question asked.

it should take a number as argument ?

Is score a number?

no it should be a string cuz as u c in my compare i check if it’s equal to F grade else … am i right ??

Your code has to match what the instructions tell you to do. The instructions tell you to use score. Is score a number or a string?

(Note, using chatspeak like ‘u c’ does make it harder to understand you.)

Please re-read Users Story #3 and #4 and follow the instructions exactly. Think of the user stories as project requirements. On the job, if you’re handed a list of project requirements to implement, would you look them over, then decide it would be better to implement them differently? I hope not…if you want to keep your job!

1 Like

ok iam sorry to use those letters , thanks for helping me i will try to re read the instructions and follow it as it be thanks again

sorry , seems i’ve problems in focus . i will try to work on it

hi Sameh,

yes, always when we write a function, we have to know what type of input it is expecting.

So if I write a function called add. I should think about what is it adding?

A function that adds numbers or a function that adds strings or something else?

Then I should think about how that value will be used inside my function to produce the desired output.

Try to do that with your function hasPassingGrade and see if you can figure out where you went wrong.

1 Like

i will do , special thanks for you all

1 Like

now i knew my mistake i fixed it , it was my fault ! i dunno how i fail in mistakes like this :slight_smile:

it is okay. You just need to always go back and read the instructions again whenever you find yourself stuck. Double check you understood everything as given. (but either way, you can always ask for help here)

you know man , i respect you all so much , the effort you do in this project is more more more than i thought , i can’t thank you enough

1 Like

keep learning and improving, and one day you will be able to give back

i hope i reach this level . i won’t give up again master , i promise i won’t