diff --git a/snippets/isLeapYear.md b/snippets/isLeapYear.md index 61ab453c3..2cc49e891 100644 --- a/snippets/isLeapYear.md +++ b/snippets/isLeapYear.md @@ -1,16 +1,14 @@ --- title: isLeapYear -tags: function,date,beginner +tags: date,beginner --- -Returns `true` if year is leap year. +Returns `true` if the given `year` is a leap year, `false` otherwise. -Use `new Date()`, set the date to 29st february `year`, check if the month is equal with 1 then return `true` +Use `new Date()`, setting the date to February 29th of the given `year` and use `Date.prototype.getMonth()` to check if the month is equal to `1`. ```js -const isLeapYear = (year) => { - return new Date(year, 1, 29).getMonth() === 1 -} +const isLeapYear = (year) => new Date(year, 1, 29).getMonth() === 1; ``` ```js