-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitchPractice.html
More file actions
146 lines (109 loc) · 3.29 KB
/
switchPractice.html
File metadata and controls
146 lines (109 loc) · 3.29 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Switch Practice</title>
</head>
<body>
<H1>Switch Practice</H1>
<script>
/*
switch () {
case x:
//executes case x code block
break:
case y:
//executes case y code block
break:
default:
//execute default code block
}
*/
/*
const day = new Date().getDay()
switch(day) {
case 0:
console.log("It's Sunday, time to relax!");
break;
case 1:
console.log("Happy Monday!");
break;
case 2:
console.log("It's Tuesday. You got this!");
break;
case 3:
console.log("Hump day already!");
break;
case 4:
console.log("Just one more day 'til the weekend!");
break;
case 5:
console.log("Happy Friday!");
break;
default:
console.log("Something went horribly wrong...");
break;
}
*/
/*
// Student Grading app
const grade = 97
switch(true) {
//if scrore is 90 or greater
case grade >= 90:
console.log("A");
break;
//if score is 80 or greater
case grade >= 80:
console.log("B");
break;
//if score is 70 or greater
case grade >= 70:
console.log("C");
break;
//if score is 60 or greater
case grade >= 60:
console.log("D");
break;
//if score is 59 or below = fail
default:
console.log("F")
}
*/
/*
// Multi-case analysis
//weeather analysis
const month = new Date().getMonth();
switch (month) {
// Jan, Feb, March
case 0:
case 1:
case 2:
console.log("Winter");
break;
// Apr, May, June
case 3:
case 4:
case 5:
console.log("Spring");
break;
// Jul, Aug, Sept
case 6:
case 7:
case 8:
console.log("Summer");
break;
// Oct, Nov, Dec
case 9:
case 10:
case 11:
console.log("Autumn");
break;
default:
console.log("Something went wrong.")
}
*/
// Foundation - Fundamentals 2 Homework
</script>
</body>
</html>