0
点赞
收藏
分享

微信扫一扫

输入年份的,输入当前的2月份的天数

witmy 2022-06-16 阅读 164

 

<script>
// 用户输入年份,输出当前年份的2月份的天数
function backDay() {
var year = prompt("请输入年份:");
if (run(year)) {
alert("当前年份是闰年2月有29天");
} else {
alert("当前年份是平年2月有28天");
}
}
backDay();

// 判断是否为闰年
function run(year) {
let a = false;
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
a = true;
}
return a;
}
console.log(run(2000));
console.log(run(2021));
</script>

 


举报

相关推荐

0 条评论