We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c57e2b commit 0e0c2f5Copy full SHA for 0e0c2f5
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -1,11 +1,13 @@
1
function getOrdinalNumber(num) {
2
- if (num % 10 === 1 && num % 100 !== 11) {
+ let remainder1 = num % 10;
3
+ let remainder2 = num % 100;
4
+ if (remainder1 === 1 && remainder2 !== 11) {
5
// we also can use if (num[-1]===1 && num.slice(-2)!==11)
6
return num + "st";
- } else if (num % 10 === 2 && num % 100 !== 12) {
7
+ } else if (remainder1 === 2 && remainder2 !== 12) {
8
// we also can use if (num[-1]===2 && num.slice(-2)!==12)
9
return num + "nd";
- } else if (num % 10 === 3 && num % 100 !== 13) {
10
+ } else if (remainder1 === 3 && remainder2 !== 13) {
11
// we also can use if (num[-1]===3 && num.slice(-2)!==13)
12
return num + "rd";
13
} else {
0 commit comments