-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamGradeCalc.js
More file actions
41 lines (28 loc) · 778 Bytes
/
ExamGradeCalc.js
File metadata and controls
41 lines (28 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Write your function here:
function finalGrade(score1, score2, score3){
const average = (score1 + score2 + score3)/3;
if (score1 < 0 || score2 < 0 || score3 < 0) {
return 'You have entered an invalid grade.';
}
if (score1 > 100 || score2 > 100 || score3 > 100) {
return 'You have entered an invalid grade.';
}
if (average <= 59) {
return 'F';
}
if (average <= 69) {
return 'D';
}
if (average <= 79) {
return 'C';
}
if (average <= 89) {
return 'B';
}
if (average <= 100) {
return 'A';
}
}
// 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!