-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentResultChecker.js
More file actions
54 lines (49 loc) · 1.07 KB
/
Copy pathStudentResultChecker.js
File metadata and controls
54 lines (49 loc) · 1.07 KB
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
const get_score = function() {
while (true) {
let score = 54;
if (score < 0 || score > 100){
console.log("Invalid score. Please enter a score between 0 and 100.");
} else {
return score;
}
}
};
const calculate_grade = function(score) {
if (score >= 80) {
return "A";
} else if (score >= 70) {
return "B" ;
} else if (score >= 50) {
return "C";
} else if (score >= 40) {
return "D";
} else {
return "E";
}
};
const get_feedback = function(grade) {
if (grade == "A") {
return "An Excellent performance.";
} else if (grade == "B") {
return "Good job, keep improving.";
} else if (grade == "C") {
return "Fair effort, keep working on it.";
} else if (grade == "D") {
return "You can do better, don't give up.";
} else {
return "Needs Improvement, Ask for help.";
}
};
let main = function() {
while (true) {
let score = get_score();
let grade = calculate_grade(score);
console.log("Grade:" + grade);
console.log("Feedback:" + get_feedback(grade));
let user_response = "no";
if (user_response == "no") {
break;
}
}
};
main();