-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitchStatement.js
More file actions
60 lines (54 loc) · 1.5 KB
/
switchStatement.js
File metadata and controls
60 lines (54 loc) · 1.5 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
55
56
57
58
59
60
// create the week calender with JS
let day = "Tuesday";
switch (day) {
case "Tuesday":
console.log("Today, is Tuesday");
break;
case "Moday":
console.log("Today is Monday");
break;
default:
console.log("Invaild Input");
break;
}
// Here is the revision of the how switch statements works- this is conditioanl statement
// let's build the grading system for the school results and this is function
let resultsFunction = (marks) => {
console.log(marks);
switch (true) {
case (marks >= 1 && marks <= 10):
console.log("You are fail");
break;
case (marks >= 11 && marks <= 20):
console.log("You are fail");
break;
case (marks >= 21 && marks <= 30):
console.log("You are fail");
break;
case (marks >= 31 && marks <= 40):
console.log("You are pass");
break;
case (marks >= 41 && marks <= 40):
console.log("You are pass");
break;
case (marks >= 51 && marks <= 60):
console.log("You are below average");
break;
case (marks >= 61 && marks <= 70):
console.log("You are average");
break;
case (marks >= 71 && marks <= 80):
console.log("You are above average");
break;
case (marks >= 81 && marks <= 90):
console.log("You are Excellent");
break;
case (marks >= 91 && marks <= 100):
console.log("You are Outstanding");
break;
default:
console.log("Invaild Input");
}
};
let outputResult = resultsFunction(101);
console.log(outputResult);