From de4cb44ef7e4987aeb99a3a0ef4d209db9605f2f Mon Sep 17 00:00:00 2001 From: Nidhish1407 Date: Thu, 27 Aug 2020 17:28:27 +0530 Subject: [PATCH] Added solution for leapYears --- leapYears/leapYears.js | 11 +++++++++-- leapYears/leapYears.spec.js | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/leapYears/leapYears.js b/leapYears/leapYears.js index ac786a2..f0ceef5 100644 --- a/leapYears/leapYears.js +++ b/leapYears/leapYears.js @@ -1,5 +1,12 @@ -const leapYears = function() { - +const leapYears = function(year) { + if(year%400==0) + return true; + else if(year%100==0) + return false; + else if(year%4==0) + return true; + else + return false; } module.exports = leapYears diff --git a/leapYears/leapYears.spec.js b/leapYears/leapYears.spec.js index 0d4d7d4..f4cdea8 100644 --- a/leapYears/leapYears.spec.js +++ b/leapYears/leapYears.spec.js @@ -4,19 +4,19 @@ describe('leapYears', function() { it('works with non century years', function() { expect(leapYears(1996)).toEqual(true); }); - xit('works with non century years', function() { + it('works with non century years', function() { expect(leapYears(1997)).toEqual(false); }); - xit('works with ridiculously futuristic non century years', function() { + it('works with ridiculously futuristic non century years', function() { expect(leapYears(34992)).toEqual(true); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(1900)).toEqual(false); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(1600)).toEqual(true); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(700)).toEqual(false); }); });