finalGrade() Challenge

While it’s giving me the proper output, it’s not passing the test. Suggestions?

Link to Exercise

// Write your function here:

const finalGrade = (averageNum) => {
  const findAverage = (num1, num2, num3) => {
    averageNum = (num1 + num2 + num3) / 3
}
  if (averageNum >= .1 && averageNum <= 59) {
   return "F"; 
  } else if (averageNum >= 60 && averageNum <= 69) {
    return "D";
  } else if (averageNum >= 70 && averageNum <= 79) {
    return "C";
  } else if (averageNum >= 80 && averageNum <= 80) {
    return "B";
  } else if (averageNum >= 90 && averageNum <= 100) {
    return "A";
  } else if (averageNum === 0 || averageNum <= 101.1)
    return "You have entered an invalid grade."
  };




// Uncomment the line below when you're ready to try out your function
console.log(finalGrade(0, 0, 0)) // Should print 'A'

// We encourage you to add more function calls of your own to test your code!

This function call:

finalGrade(99, 92, 100.5);

will result in "A". Is this correct?

If any of the grades passed in are less than 0 or greater than 100, the function should return ‘You have entered an invalid grade.’

Your function should take three arguments, it takes only one.


This comparison:

averageNum >= .1

is messy, what if averageNum is 0.05? Or 0.000005?

1 Like