-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrasshoperGradeBook.js
37 lines (28 loc) · 985 Bytes
/
GrasshoperGradeBook.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
36
37
//---Description---
//Complete the function so that it finds the average of the three scores
// passed to it and returns the letter value associated with that grade.
// Numerical Score Letter Grade
// 90 <= score <= 100 'A'
// 80 <= score < 90 'B'
// 70 <= score < 80 'C'
// 60 <= score < 70 'D'
// 0 <= score < 60 'F'
//Tested values are all between 0 and 100.
// There is no need to check for negative values or values greater than 100.
function getGrade (s1, s2, s3) {
const average = Math.round((s1 + s2 + s3) / getGrade.length)
console.log(average)
let score
if (average >= 90 && average <= 100 ) {
return score = 'A'
} else if(average >= 80 && average <= 90) {
return score = 'B'
} else if(average >= 70 && average <= 80) {
return score = 'C'
} else if(average >= 60 && average <= 70) {
return score = 'D'
} else if(average >= 0 && average <= 60) {
return score = 'F'
}
console.log(score)
}