代码:
var d = 5
switch (d) {
case 1:
x = "今天是星期一";
break;
case 2:
x = "今天是星期二";
break;
case 3:
x = "今天是星期三";
break;
case 4:
x = "今天是星期四";
break;
case 5:
x = "今天是星期五";
break;
case 6:
x = "今天是星期六";
break;
default:
x = "今天是星期日";
}
console.log(x)
输出:
今天是星期五