-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch.js
More file actions
47 lines (39 loc) · 715 Bytes
/
switch.js
File metadata and controls
47 lines (39 loc) · 715 Bytes
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
//: Switch Statement
//* The switch statement is used to perform different actions beased on different conditiond
//! syntax
// switch (expression) {
// case x:
// // code block
// break;
// case y:
// // code block
// break;
// default:
// // code block
// }
//# the break keyword
// The break statement breaks out of a switch or a loop.
var day;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
console.log(day);