CODE CHALLENGES: JAVASCRIPT FUNDAMENTALS finalGrade()

Hi guys! I’m trying to solve the finalGrade() in Javascript fundementals and it seems my code is correct and gives out the correct answer but ‘Instructions’ wont accept it as correct. What is wrong with my code?
(https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/code-challenge-javascript-fundamentals/lessons/javascript-fundamentals-code-challenge/exercises/final-grade)

// Write your function here:

const finalGrade = (grade1, grade2, grade3) => {

  
  totalGrade = grade1 + grade2 + grade3;
  averageGrade = totalGrade / 3;
  
  if (averageGrade < 0 || averageGrade > 100 || grade1 < 0 || grade2 < 0 || grade3 < 0 || grade1 > 100 || grade2 > 100 || grade3 > 100) 
  
  {
    console.log('You have entered an invalid grade.')
  }
 else if (averageGrade <= 59) {
    console.log('F')
  }
  else if (averageGrade <= 69) {
    console.log('D')
  }
  else if (averageGrade <= 79) {
    console.log('C')
  }
  else if (averageGrade <= 89) {
    console.log('B')
  }
  else if (averageGrade <= 100) {
    console.log('A')
  }
  else {
    console.log('Error in grading')
  }
  
}




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

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

Thanks a lot in advance!

1 Like

one of the instructions points:

return the letter grade (as a string) that the average corresponds to

your function only seems to log the letter grade

2 Likes

That was totally it! Thank you for taking your time to help me.

1 Like