File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
- const leapYears = function ( ) {
1
+ const leapYears = function ( year ) {
2
+ if ( year % 4 === 0 && year % 100 !== 0 || year % 400 === 0 ) {
3
+ return true ;
4
+ }
5
+ if ( year % 100 === 0 ) {
6
+ return false
7
+ }
8
+ if ( year % 4 === 1 ) {
9
+ return false
10
+ }
2
11
3
12
}
4
13
Original file line number Diff line number Diff line change @@ -4,19 +4,19 @@ describe('leapYears', function() {
4
4
it ( 'works with non century years' , function ( ) {
5
5
expect ( leapYears ( 1996 ) ) . toEqual ( true ) ;
6
6
} ) ;
7
- xit ( 'works with non century years' , function ( ) {
7
+ it ( 'works with non century years' , function ( ) {
8
8
expect ( leapYears ( 1997 ) ) . toEqual ( false ) ;
9
9
} ) ;
10
- xit ( 'works with ridiculously futuristic non century years' , function ( ) {
10
+ it ( 'works with ridiculously futuristic non century years' , function ( ) {
11
11
expect ( leapYears ( 34992 ) ) . toEqual ( true ) ;
12
12
} ) ;
13
- xit ( 'works with century years' , function ( ) {
13
+ it ( 'works with century years' , function ( ) {
14
14
expect ( leapYears ( 1900 ) ) . toEqual ( false ) ;
15
15
} ) ;
16
- xit ( 'works with century years' , function ( ) {
16
+ it ( 'works with century years' , function ( ) {
17
17
expect ( leapYears ( 1600 ) ) . toEqual ( true ) ;
18
18
} ) ;
19
- xit ( 'works with century years' , function ( ) {
19
+ it ( 'works with century years' , function ( ) {
20
20
expect ( leapYears ( 700 ) ) . toEqual ( false ) ;
21
21
} ) ;
22
22
} ) ;
You can’t perform that action at this time.
0 commit comments