Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 2, 2018 23:52
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/d69aa25461f0873a4416eb15879d2eb9 to your computer and use it in GitHub Desktop.
Save codecademydev/d69aa25461f0873a4416eb15879d2eb9 to your computer and use it in GitHub Desktop.
Codecademy export
// Write your function here:
function finalGrade(test, quiz, final) {
const ave = (test + quiz + final)/3;
if ((test < 0 || test > 100) || (quiz < 0 || quiz > 100) || (final < 0 || final > 100)) {
console.log('You have entered an invalid grade.');
} else if(ave >= 0 && ave < 60) {
return 'F';
} else if(ave > 59 && ave < 70) {
return 'D';
} else if(ave > 69 && ave < 80) {
return 'C';
} else if(ave > 79 && ave < 90) {
return 'B';
} else if(ave > 89 && ave <= 100) {
return 'A';
}
}
// Uncomment the line below when you're ready to try out your function
console.log(finalGrade(101, 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