From 9bd8c4d3406b520e3d24a89982d0118486f778bb Mon Sep 17 00:00:00 2001 From: Isabella Thurmond Date: Thu, 1 Jul 2021 14:14:52 -0700 Subject: [PATCH] implemented solutions to hello world and leap year --- helloWorld/helloWorld.js | 4 ++-- leapYears/leapYears.js | 16 +++++++++++++++- leapYears/leapYears.spec.js | 11 ++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/helloWorld/helloWorld.js b/helloWorld/helloWorld.js index df27036..7099f70 100644 --- a/helloWorld/helloWorld.js +++ b/helloWorld/helloWorld.js @@ -1,5 +1,5 @@ -const helloWorld = function() { - return '' +const helloWorld = () => { + return 'Hello, World!' }; module.exports = helloWorld; diff --git a/leapYears/leapYears.js b/leapYears/leapYears.js index 68e3af8..bf17a26 100644 --- a/leapYears/leapYears.js +++ b/leapYears/leapYears.js @@ -1,5 +1,19 @@ -const leapYears = function() { +const leapYears = (year) => { + const modulo = year % 4; + if (modulo === 0 ){ + if(year % 100 === 0){ + if (year % 400 === 0){ + return true; + } else { + return false; + } + } + return true; + + } + return false; }; module.exports = leapYears; + diff --git a/leapYears/leapYears.spec.js b/leapYears/leapYears.spec.js index 6fdaba9..79620ec 100644 --- a/leapYears/leapYears.spec.js +++ b/leapYears/leapYears.spec.js @@ -4,19 +4,20 @@ 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); }); });