// 輸入月份,顯示當月的天數
// 要求:利用case落空簡化代碼 如果是2月 則默認為28天即可
<script>
1 3 5 7 8 10 12 31天
4 6 9 11 30天
2 28天
var month = +prompt("請輸入月份");
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
alert("31天");
break;
case 4:
case 6:
case 9:
case 11:
alert("30天");
break;
case 2:
alert("28天");
break;
default:
alert("錯誤的月份");
break;
}
</script>