The format of the stwith statement is generally as follows:
The code copy is as follows:
switch (expression){
case value :statement1
break;
case value2 :statement2
break;
....
case value: statement
break;
default :statement;
Each case indicates that if the value of expression is equal to case, then a statament is executed.
The keyword break makes the code jump out of the switch.
If there is no keyword break, the code continues to execute the next situation. The keyword default is the result of execution when all expression values are not equal to the value value.
The code copy is as follows:
iwork = parseInt(prompt("Please enter the value of 1-5"));
switch (iwork) {
case 1: document.write("Monday")
break;
case 2 : "2 of the week"
break;
case 3 : "3 of the week"
break;
case 4 : "4 of the week"
break;
case 5 : "5th of the week"
break;
default :"Enter reasonable value";