-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent's Final Grade.js
43 lines (31 loc) · 1.25 KB
/
Student's Final Grade.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
/*
Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects.
This function should take two arguments: exam - grade for exam (from 0 to 100); projects - number of completed projects (from 0 and above);
This function should return a number (final grade). There are four types of final grades:
100, if a grade for the exam is more than 90 or if a number of completed projects more than 10.
90, if a grade for the exam is more than 75 and if a number of completed projects is minimum 5.
75, if a grade for the exam is more than 50 and if a number of completed projects is minimum 2.
0, in other cases
Examples(Inputs-->Output):
100, 12 --> 100
99, 0 --> 100
10, 15 --> 100
85, 5 --> 90
55, 3 --> 75
55, 0 --> 0
20, 2 --> 0
*Use Comparison and Logical Operators.
*/
// Сылка на катту: https://www.codewars.com/kata/5ad0d8356165e63c140014d4/train/javascript
//Решение 1:
function finalGrade(exam, projects) {
if (exam > 90 || projects > 10) {
return 100;
}else if (exam > 75 && projects >= 5){
return 90;
}else if (exam > 50 && projects >= 2) {
return 75;
}else{
return 0;
}
}