Created
July 27, 2020 19:34
-
-
Save Blackman54/f4190eff2be2b591cd159aa2db51c703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function | |
const sumOfFinalGrade = (test, homework, exam) => { | |
// if (test < 0 || test > 100 || homework < 0 || homework > 100 || exam < 0 || exam > 100){ | |
// return 'You have entered an invalid grade.'; | |
// } | |
return test + homework + exam; | |
}; | |
// function | |
const finalGrade = (test, homework, exam) => { | |
if (test < 0 || test > 100 || homework < 0 || homework > 100 || exam < 0 || exam > 100){ | |
return 'You have entered an invalid grade.'; | |
} | |
const average = sumOfFinalGrade(test, homework, exam) / 3; | |
if (average <= 59) { | |
return 'F' | |
} else if (average <= 69) { | |
return 'D' | |
} else if (average <= 79) { | |
return 'C' | |
} else if (average <= 89) { | |
return 'B' | |
} else if (average <= 100) { | |
return 'A' | |
} | |
}; | |
// output | |
console.log(finalGrade(-1, 92, 95)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please i have been Struggling with LINE 3 and 4, i am trying to move Line 3 and 4 to finalGrade function without rewriting the if else statement like i did in Line 11 and 12.. ! Thanks