【发布时间】:2021-04-15 22:15:22
【问题描述】:
我正在学习关于 Udemy 的课程,但我对问题的解决方案感到困惑。问题是创建一个函数来确定一年是否为闰年。
解决办法是:
function isLeap(year) {
/**************Don't change the code above****************/
//Write your code here.
if (year % 4 === 0){
if (year % 100 === 0){
if (year % 400 === 0){
return ("Leap year.")
}
} else {
return ("Leap year.")
}
} else {
return ("Not leap year.")
}
isLeap(1948);
/**************Don't change the code below****************/
}
如果满足这些条件,当上面已经使用else return ("Leap year") 时,我对它的使用感到困惑。我是否遗漏了与代码流动方式有关的内容?
【问题讨论】:
-
如果你修复你的大括号和缩进,你会看到你缺少什么。
标签: javascript function if-statement