switch的穿透作用计算当前日期是这一年的第几天
var y =2020;
var m = 04;
var d =22;
var sum = 0
switch(m){
case 12:
sum += 30;
case 11:
sum += 31;
case 10:
sum += 30;
case 9:
sum += 31;
case 8:
sum += 31;
case 7:
sum += 30;
case 6:
sum += 31;
case 5:
sum += 30;
case 4:
sum += 31;
case 3:
if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)){
sum += 29;
}else{
sum += 28;
}
case 2:
sum += 31;
case 1:
sum += d; break
default:
console.log("你输入的日期不符合规范")
}
console.log("今天是2020年的第"+sum)