File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ function getOrdinalNumber(num) {
44 throw new Error ( "Input must be a valid number" ) ;
55 }
66
7- const lastnum = num % 10 ; // checks what last number is
8- const last2num = num % 100 ; // checks what last two numbers are, needed to check for 11
7+ const lastNum = num % 10 ; // checks what last number is
8+ const last2Num = num % 100 ; // checks what last two numbers are, needed to check for 11
99
10- if ( last2num === 11 || last2num === 12 || last2num == = 13 ) {
10+ if ( last2Num >= 11 && last2Num < = 13 ) {
1111 return num + "th" ;
1212 }
13- if ( lastnum === 1 ) return num + "st" ;
14- if ( lastnum === 2 ) return num + "nd" ;
15- if ( lastnum === 3 ) return num + "rd" ;
13+ if ( lastNum === 1 ) return num + "st" ;
14+ if ( lastNum === 2 ) return num + "nd" ;
15+ if ( lastNum === 3 ) return num + "rd" ;
1616
1717 return num + "th" ;
1818}
You can’t perform that action at this time.
0 commit comments