Files
jveneziano25 3c636bebee Leap Years: Use more appropriate solution (#483)
Replacement solution is closer to what most learners might think of due to the instructions' hints, and concepts they'll have been reasonably exposed to so far in the curriculum.
The original solution has been a curveball for quite a few people.

Co-authored-by: Josh Veneziano <jveneziano@proton.me>
2024-06-27 12:25:01 +01:00

17 lines
353 B
JavaScript

const leapYears = function (year) {
const isYearDivisibleByFour = year % 4 === 0;
const isCentury = year % 100 === 0;
const isYearDivisibleByFourHundred = year % 400 === 0;
if (
isYearDivisibleByFour &&
(!isCentury || isYearDivisibleByFourHundred)
) {
return true;
} else {
return false;
}
};
module.exports = leapYears;