@@ -22,30 +22,31 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
2222// Case 2: Numbers ending with 2 (but not 12)
2323// When the number ends with 2, except for those ending with 12,
2424// Then the function should return a string by appending "nd" to the number.
25- test ( "returns 'nd' for 2, 22, 102 " , ( ) => {
26- expect ( getOrdinalNumber ( 2 ) ) . toBe ( "2nd" ) ;
27- expect ( getOrdinalNumber ( 22 ) ) . toBe ( "22nd" ) ;
28- expect ( getOrdinalNumber ( 102 ) ) . toBe ( "102nd" ) ;
29- } ) ;
25+ test ( "appends 'nd' for numbers ending with 2, except those ending with 12 " , ( ) => {
26+ expect ( getOrdinalNumber ( 2 ) ) . toBe ( "2nd" ) ;
27+ expect ( getOrdinalNumber ( 22 ) ) . toBe ( "22nd" ) ;
28+ expect ( getOrdinalNumber ( 102 ) ) . toBe ( "102nd" ) ;
29+ } ) ;
3030
3131// Case 3: Numbers ending with 3 (but not 13)
3232// When the number ends with 3, except for those ending with 13,
3333// Then the function should return a string by appending "rd" to the number.
34- test ( "returns 'rd' for 3, 23, 103 " , ( ) => {
35- expect ( getOrdinalNumber ( 3 ) ) . toBe ( "3rd" ) ;
36- expect ( getOrdinalNumber ( 23 ) ) . toBe ( "23rd" ) ;
37- expect ( getOrdinalNumber ( 103 ) ) . toBe ( "103rd" ) ;
38- } ) ;
34+ test ( "appends 'rd' for numbers ending in 3, except those ending in 13 " , ( ) => {
35+ expect ( getOrdinalNumber ( 3 ) ) . toBe ( "3rd" ) ;
36+ expect ( getOrdinalNumber ( 23 ) ) . toBe ( "23rd" ) ;
37+ expect ( getOrdinalNumber ( 103 ) ) . toBe ( "103rd" ) ;
38+ } ) ;
3939
4040// Case 4: All other numbers including umbers ending with 11, 12 or 13
4141// These are for all other numbers including special cases and should always end with "th",
4242// Then the function should return a string by appending "th" to the number.
43- test ( "returns 'th' for all other numbers including those ending with 11, 12, 13" , ( ) => {
44- expect ( getOrdinalNumber ( 11 ) ) . toBe ( "11th" ) ;
45- expect ( getOrdinalNumber ( 12 ) ) . toBe ( "12th" ) ;
46- expect ( getOrdinalNumber ( 13 ) ) . toBe ( "13th" ) ;
47- expect ( getOrdinalNumber ( 10 ) ) . toBe ( "10th" ) ;
48- expect ( getOrdinalNumber ( 99 ) ) . toBe ( "99th" ) ;
49- expect ( getOrdinalNumber ( 100 ) ) . toBe ( "100th" ) ;
50-
51- } ) ;
43+ test ( "returns 'th' for all numbers ending with 4-9 or 0 including numbers ending with 11, 12 and 13" , ( ) => {
44+ expect ( getOrdinalNumber ( 11 ) ) . toBe ( "11th" ) ;
45+ expect ( getOrdinalNumber ( 12 ) ) . toBe ( "12th" ) ;
46+ expect ( getOrdinalNumber ( 13 ) ) . toBe ( "13th" ) ;
47+ expect ( getOrdinalNumber ( 10 ) ) . toBe ( "10th" ) ;
48+ expect ( getOrdinalNumber ( 5 ) ) . toBe ( "5th" ) ;
49+ expect ( getOrdinalNumber ( 8 ) ) . toBe ( "8th" ) ;
50+ expect ( getOrdinalNumber ( 99 ) ) . toBe ( "99th" ) ;
51+ expect ( getOrdinalNumber ( 100 ) ) . toBe ( "100th" ) ;
52+ } ) ;
0 commit comments