javascript---按年/月/日的顺序输入一个任意日期,在页面输出:这是这一年的第几天
var year = parseInt(prompt("请输入年")); var month = parseInt(prompt("请输入月")); var day = parseInt(prompt("请输入日")); var sum = 0; switch(month - 1){ case 11: sum += 30; case 10: sum += 31; case 9: sum += 30; case 8: sum += 31; case 7: sum += 31; case 6: sum += 30; case 5: sum += 31; case 4: sum += 30; case 3: sum += 31; case 2: //判断闰年 闰年2月29天 if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 ==0)){ sum += 29; }else { sum += 28; } case 1: sum += 31; break } sum += day; document.write("这是" + year + "的第" + sum + "天");