Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 3, 2020 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/17d1437955cd2d2ca7ffa2bc346c738d to your computer and use it in GitHub Desktop.
Save codecademydev/17d1437955cd2d2ca7ffa2bc346c738d to your computer and use it in GitHub Desktop.
Codecademy export
// Write your function here:
const finalGrade = (num1, num2, num3)=>{
if (num1 < 0 || num2 < 0 || num3 < 0 || num1 > 100 || num2 > 100 || num3 > 100 ){
return 'You have entered an invalid grade.'
};
const average = ((num1 + num2 + num3))/3;
if (average>=0 & average<=59){
return 'F'
} else if (average >=60 & average<=69){
return "D"
} else if (average >=70 & average <=79){
return "C"
} else if (average >=80 & average <=89){
return "B"
}else if(average >=90 & average <=100){
return "A"
} else {return "Invalid Code, check the programm"}
};
// 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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment