switch statement based on different conditions to perform different actions.
switch (expression) { Case n- : block BREAK; Case n- : block BREAK; default: default block }
Code explanation:
- Calculated once the switch expression
- The value of the expression is compared with the value for each case of
- If there is a match, then the association code execution
as follows:
Switch (. new new a 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"; }