Functioning code for leapYear exercise
This commit is contained in:
parent
a6cb3200c3
commit
1b8d812b78
|
@ -1,5 +1,13 @@
|
|||
const leapYears = function() {
|
||||
|
||||
const leapYears = function(date) {
|
||||
if (date % 4 === 0) {
|
||||
if (date % 100 === 0 && date % 400 !== 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = leapYears
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue