<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>计算天数</title>
</head>
<body>
<script>
var year=prompt("请输入您的出生年份"),
month=prompt(("请输入您的出生月份"),
day=prompt(("请输入您的出生日期"),
monthnum=parseInt(month),
yearnum=parseInt(year),
daynum=parseInt(day),
sum=0,
i;
if(yearnum%4==0 && yearnum%100!=0){
function num2(){
for(i=0;i<monthnum;i++){sum+=arguments[i]}
return sum;
}
}
else if(yearnum%400==0){
function num2{
for(i=0;i<monthnum;i++){sum+=arguments[i]}
return sum;
}
}
else{function num1{
for(i=0;i<monthnum;i++){sum+=arguments[i]}
return sum;
}}
num1(31,28,31,30,31,30,31,31,30,31,30,31);
num2(31,29,31,30,31,30,31,31,30,31,30,31);
var total=sum-daynum
console.log("您的生日在"+yearnum+"年"+"第"+total+"天")
</script>
</body>
</html>
日光弥散
前端绅士
相关分类