-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05_ifElse.js
65 lines (60 loc) · 1.53 KB
/
05_ifElse.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Task
Complete the getGrade(score) function in the editor.
It has one parameter: an integer, score, denoting the number of points Julia earned on an exam.
It must return the letter corresponding to her grade according to the following rules
Rules:
if 25 < score <= 30 then grade=A;
if 20 < score <= 25 then grade=B;
if 15 < score <= 20 then grade=C;
if 10 < score <= 15 then grade=D;
if 05 < score <= 10 then grade=E;
if 00 < score <= 05 then grade=F;
*/
function getGrade(score) {
let grade;
// Write your code here
if(score>25 && score <= 30){
grade="A";
}
else if(score >20 && score <= 25){
grade="B";
}
else if(score>15 && score <= 20){
grade="C";
}
else if(score>10 && score <=15){
grade ="D";
}
else if(score>5 && score <=10){
grade="E"
}
else{
grade="F";
}
return grade;
}
function getGradee(score){
let grade;
switch(true){
case score>25 && score <= 30:
grade='A';
break;
case score>20 && score <= 25:
grade='B';
break;
case score>15 && score <= 20:
grade='C';
break;
case score>10 && score <= 15:
grade='D';
break;
case score>5 && score <= 10:
grade='E';
break;
default:
grade='F';
}
return grade;
}
console.log(getGrade(11));