switch.case multi-branch statement
effect: provides several features similar to the if-else branch cascade, but the code and readable
syntax:
with the 1.switch followed by the expression or shaping the character
with a back 2.case constant shaping or characters
3.break; for the end of the current statement
that follows the default codes else if-else if the value of 4.default similar case are unable to meet the expression matching is executed.
Input box promot (user prompt)
little exercise to determine the number of input output summer spring 2. 3. 4. Autumn Winter no other output this season
var s = prompt("请输入一个数字");
switch(parseInt(s)){
case 1:
alert("春天");
break;
case 2:
alert("夏天");
break;
case 3:
alert("秋天");
break;
default:
alert("冬天");
break;
}