@@ -13,8 +13,7 @@ describe("calculateMedian", () => {
1313 { input : [ 1 , 2 , 3 , 4 ] , expected : 2.5 } ,
1414 { input : [ 1 , 2 , 3 , 4 , 5 , 6 ] , expected : 3.5 } ,
1515 ] . forEach ( ( { input, expected } ) =>
16- it ( `returns the median for [${ input } ]` , ( ) =>
17- expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
16+ it ( `returns the median for [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
1817 ) ;
1918
2019 [
@@ -25,8 +24,7 @@ describe("calculateMedian", () => {
2524 { input : [ 110 , 20 , 0 ] , expected : 20 } ,
2625 { input : [ 6 , - 2 , 2 , 12 , 14 ] , expected : 6 } ,
2726 ] . forEach ( ( { input, expected } ) =>
28- it ( `returns the correct median for unsorted array [${ input } ]` , ( ) =>
29- expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
27+ it ( `returns the correct median for unsorted array [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
3028 ) ;
3129
3230 it ( "doesn't modify the input array [3, 1, 2]" , ( ) => {
@@ -35,17 +33,8 @@ describe("calculateMedian", () => {
3533 expect ( list ) . toEqual ( [ 3 , 1 , 2 ] ) ;
3634 } ) ;
3735
38- [
39- "not an array" ,
40- 123 ,
41- null ,
42- undefined ,
43- { } ,
44- [ ] ,
45- [ "apple" , null , undefined ] ,
46- ] . forEach ( ( val ) =>
47- it ( `returns null for non-numeric array (${ val } )` , ( ) =>
48- expect ( calculateMedian ( val ) ) . toBe ( null ) )
36+ [ 'not an array' , 123 , null , undefined , { } , [ ] , [ "apple" , null , undefined ] ] . forEach ( val =>
37+ it ( `returns null for non-numeric array (${ val } )` , ( ) => expect ( calculateMedian ( val ) ) . toBe ( null ) )
4938 ) ;
5039
5140 [
@@ -56,7 +45,6 @@ describe("calculateMedian", () => {
5645 { input : [ 3 , "apple" , 1 , null , 2 , undefined , 4 ] , expected : 2.5 } ,
5746 { input : [ "banana" , 5 , 3 , "apple" , 1 , 4 , 2 ] , expected : 3 } ,
5847 ] . forEach ( ( { input, expected } ) =>
59- it ( `filters out non-numeric values and calculates the median for [${ input } ]` , ( ) =>
60- expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
48+ it ( `filters out non-numeric values and calculates the median for [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
6149 ) ;
62- } ) ;
50+ } ) ;
0 commit comments