Merge branch 'master' of TOP/javascript-exercises

This commit is contained in:
Michael Frank
2021-05-09 00:29:44 +12:00
2932 changed files with 302449 additions and 87 deletions
+1 -3
View File
@@ -2,9 +2,7 @@
Create a function that determines whether or not a given year is a leap year. Leap years are determined by the following rules:
> Leap years are years divisible by four (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are divisible by 400 (like 1600 and 2000, which were in fact leap years). (Yes, it's all pretty confusing)
>
> -- <cite>[Learn to Program](https://pine.fm/LearnToProgram/chap_06.html) by Chris Pine</cite>
>There is a leap year every year whose number is perfectly divisible by four - except for years evenly divisible by 100, which are not leap years unless evenly divisible by 400. The second part of the rule affects century years. For example; the century years 1600 and 2000 are leap years, but the century years 1700, 1800, and 1900 are not.
```javascript
leapYears(2000) // is a leap year: returns true
+2 -2
View File
@@ -1,5 +1,5 @@
const leapYears = function() {
var leapYears = function(year) {
return year % 4 === 0 && ( year % 100 !== 0 || year % 400 == 0)
}
module.exports = leapYears