implemented solutions to hello world and leap year

This commit is contained in:
Isabella Thurmond 2021-07-01 14:14:52 -07:00
parent 9c3bcb49f8
commit 9bd8c4d340
3 changed files with 23 additions and 8 deletions

View File

@ -1,5 +1,5 @@
const helloWorld = function() { const helloWorld = () => {
return '' return 'Hello, World!'
}; };
module.exports = helloWorld; module.exports = helloWorld;

View File

@ -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; module.exports = leapYears;

View File

@ -4,19 +4,20 @@ describe('leapYears', () => {
test('works with non century years', () => { test('works with non century years', () => {
expect(leapYears(1996)).toBe(true); expect(leapYears(1996)).toBe(true);
}); });
test.skip('works with non century years', () => {
test('works with non century years', () => {
expect(leapYears(1997)).toBe(false); 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); expect(leapYears(34992)).toBe(true);
}); });
test.skip('works with century years', () => { test('works with century years', () => {
expect(leapYears(1900)).toBe(false); expect(leapYears(1900)).toBe(false);
}); });
test.skip('works with century years', () => { test('works with century years', () => {
expect(leapYears(1600)).toBe(true); expect(leapYears(1600)).toBe(true);
}); });
test.skip('works with century years', () => { test('works with century years', () => {
expect(leapYears(700)).toBe(false); expect(leapYears(700)).toBe(false);
}); });
}); });