From f8b292fa9f3698a58b8a34068616603c59eb8677 Mon Sep 17 00:00:00 2001 From: Thuan Bui <9248622+10h30@users.noreply.github.com> Date: Sat, 22 Feb 2025 10:46:02 +0900 Subject: [PATCH] Complete 6 --- 06_leapYears/leapYears.js | 17 +++++++++++++++-- 06_leapYears/leapYears.spec.js | 10 +++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/06_leapYears/leapYears.js b/06_leapYears/leapYears.js index 681eeef..c271454 100644 --- a/06_leapYears/leapYears.js +++ b/06_leapYears/leapYears.js @@ -1,5 +1,18 @@ -const leapYears = function() { - +const leapYears = function(year) { + if (year%4 === 0 ) { + if (year % 100 === 0) { + if (year % 400 === 0) { + return true; + } + else { + return false + } + } + return true; + } + else { + return false + } }; // Do not edit below this line diff --git a/06_leapYears/leapYears.spec.js b/06_leapYears/leapYears.spec.js index 6fdaba9..2cd4110 100644 --- a/06_leapYears/leapYears.spec.js +++ b/06_leapYears/leapYears.spec.js @@ -4,19 +4,19 @@ describe('leapYears', () => { test('works with non century years', () => { expect(leapYears(1996)).toBe(true); }); - test.skip('works with non century years', () => { + test('works with non century years', () => { expect(leapYears(1997)).toBe(false); }); - test.skip('works with ridiculously futuristic non century years', () => { + test('works with ridiculously futuristic non century years', () => { expect(leapYears(34992)).toBe(true); }); - test.skip('works with century years', () => { + test('works with century years', () => { expect(leapYears(1900)).toBe(false); }); - test.skip('works with century years', () => { + test('works with century years', () => { expect(leapYears(1600)).toBe(true); }); - test.skip('works with century years', () => { + test('works with century years', () => { expect(leapYears(700)).toBe(false); }); });