Added solution for leapYears

This commit is contained in:
Nidhish1407 2020-08-27 17:28:27 +05:30
parent 3faf02d030
commit de4cb44ef7
2 changed files with 14 additions and 7 deletions

View File

@ -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

View File

@ -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);
});
});