-
Notifications
You must be signed in to change notification settings - Fork 1
/
9. Switch_Statements
53 lines (48 loc) · 924 Bytes
/
9. Switch_Statements
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
// switch(expression) {
// case x:
// // code block
// break;
// case y:
// // code block
// break;
// default:
// // code block
// }
let x = "0";
switch (x) {
case 0:
text = "Off";
break;
case 1:
text = "On";
break;
default:
text = "No value found";
}
// -------------------------------------------------
let day = "monday";
switch (day) {
case "monday":
console.log("Today is monday");
break;
case "tuesday":
console.log("Today is tuesday");
break;
case "wednesday":
console.log("Today is wednesday");
break;
case "tuesday":
console.log("Today is thursday");
break;
case "friday":
console.log("Today is friday");
break;
case "saturday":
console.log("Today is saturday");
break;
case "sunday":
console.log("Today is sunday");
break;
default:
console.log("Don't know what day is today!");
}