I am doing a course on Udemy and I'm confused by the solution to the problem. The problem is to create a function that determines whether a year is a leap year.
The solution is:
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****************/
}
I am confused by the use of else return ("Leap year")
when it is already used above for if those conditions are met. Am I missing something to do with how the code flows?