@@ -18,27 +18,38 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
1818 expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
1919 expect ( getOrdinalNumber ( 131 ) ) . toEqual ( "131st" ) ;
2020} ) ;
21- // Case 1 : Numbers ending with 1 (but not 11 )
22- // When the number ends with 1, except those ending with 11 ,
21+ // Case 2 : Numbers ending with 2 (but not 12 )
22+ // When the number ends with 1, except those ending with 12 ,
2323// Then the function should return a string by appending "st" to the number.
2424test ( "should append 'nd' for numbers ending with 2, except those ending with 12" , ( ) => {
2525 expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
2626 expect ( getOrdinalNumber ( 42 ) ) . toEqual ( "42nd" ) ;
2727 expect ( getOrdinalNumber ( 1752 ) ) . toEqual ( "1752nd" ) ;
2828} ) ;
29- // Case 1 : Numbers ending with 1 (but not 11 )
30- // When the number ends with 1 , except those ending with 11 ,
29+ // Case 3 : Numbers ending with 3 (but not 13 )
30+ // When the number ends with 3 , except those ending with 13 ,
3131// Then the function should return a string by appending "st" to the number.
3232test ( "should append 'rd' for numbers ending with 3, except those ending with 13" , ( ) => {
3333 expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
3434 expect ( getOrdinalNumber ( 83 ) ) . toEqual ( "83rd" ) ;
3535 expect ( getOrdinalNumber ( 653 ) ) . toEqual ( "653rd" ) ;
3636} ) ;
37- // Case 1 : Numbers ending with 1 (but not 11)
38- // When the number ends with 1, except those ending with 11 ,
39- // Then the function should return a string by appending "st " to the number.
40- test ( "should append 'th' for numbers not ending with 1, 2 and 3 " , ( ) => {
37+ // Case 4 : Numbers ending with 4 through 9
38+ // When the number does not end with 1, 2 or 3 ,
39+ // Then the function should return a string by appending "th " to the number.
40+ test ( "should append 'th' for all other numbers that do not end with 1, 2 or 3 " , ( ) => {
4141 expect ( getOrdinalNumber ( 5 ) ) . toEqual ( "5th" ) ;
4242 expect ( getOrdinalNumber ( 38 ) ) . toEqual ( "38th" ) ;
4343 expect ( getOrdinalNumber ( 15678 ) ) . toEqual ( "15678th" ) ;
4444} ) ;
45+ //Case 5: Numbers ending with 11, 12 and 13 (special exceptions)
46+ // When the number ends with 11, 12 or 13,
47+ // Then the function should return a string by appending "th" to the number.
48+ test ( "should append 'th' for numbers ending with 11, 12 and 13" , ( ) => {
49+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
50+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
51+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
52+ expect ( getOrdinalNumber ( 111 ) ) . toEqual ( "111th" ) ;
53+ expect ( getOrdinalNumber ( 112 ) ) . toEqual ( "112th" ) ;
54+ expect ( getOrdinalNumber ( 113 ) ) . toEqual ( "113th" ) ;
55+ } ) ;
0 commit comments