File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ function getOrdinalNumber(num) {
22 let lastDigit = num % 10 ;
33 let lastTwoDigits = num % 100 ;
44 if ( lastDigit === 1 && lastTwoDigits !== 11 ) {
5- // we also can use if (num[-1] ==="1" && num.slice(-2)!=="11")
5+ // we also can use if (num.slice(-1) ==="1" && num.slice(-2)!=="11")
66 return num + "st" ;
77 } else if ( lastDigit === 2 && lastTwoDigits !== 12 ) {
8- // we also can use if (num[-1] ==="2" && num.slice(-2)!=="12")
8+ // we also can use if (num.slice(-1) ==="2" && num.slice(-2)!=="12")
99 return num + "nd" ;
1010 } else if ( lastDigit === 3 && lastTwoDigits !== 13 ) {
11- // we also can use if (num[-1] ==="3" && num.slice(-2)!=="13")
11+ // we also can use if (num.slice(-1) ==="3" && num.slice(-2)!=="13")
1212 return num + "rd" ;
1313 } else {
1414 return num + "th" ;
You can’t perform that action at this time.
0 commit comments