Skip to content

Commit 02245db

Browse files
committed
renamed variables
1 parent 75c15af commit 02245db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sprint-3/2-practice-tdd/get-ordinal-number.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
function getOrdinalNumber(num) {
2-
let remainder1 = num % 10;
3-
let remainder2 = num % 100;
4-
if (remainder1 === 1 && remainder2 !== 11) {
2+
let lastDigit = num % 10;
3+
let lastTwoDigits = num % 100;
4+
if (lastDigit === 1 && lastTwoDigits !== 11) {
55
// we also can use if (num[-1]===1 && num.slice(-2)!==11)
66
return num + "st";
7-
} else if (remainder1 === 2 && remainder2 !== 12) {
7+
} else if (lastDigit === 2 && lastTwoDigits !== 12) {
88
// we also can use if (num[-1]===2 && num.slice(-2)!==12)
99
return num + "nd";
10-
} else if (remainder1 === 3 && remainder2 !== 13) {
10+
} else if (lastDigit === 3 && lastTwoDigits !== 13) {
1111
// we also can use if (num[-1]===3 && num.slice(-2)!==13)
1212
return num + "rd";
1313
} else {

0 commit comments

Comments
 (0)