-
Notifications
You must be signed in to change notification settings - Fork 0
/
GradeBook.js
35 lines (27 loc) · 800 Bytes
/
GradeBook.js
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
// Write a function that determines the mean (average) of the three scores passed to it, and returns the letter associated with that grade.
const getGrade = (grade1, grade2, grade3) => {
let average = ((grade1 + grade2 + grade3) / 3);
return letterGrade(average);
}
const letterGrade = (avg) => {
switch (true) {
case avg < 60:
return "F";
break;
case avg < 70:
return "D";
break;
case avg < 80:
return "C";
break;
case avg < 90:
return "B";
break;
default:
return "A";
}
return avg;
}
console.log(getGrade(95, 90, 93)); // "A"
console.log(getGrade(50, 50, 95)); // "D"
console.log(getGrade(75, 82, 95)); // "D"