Skip to content

Commit a124398

Browse files
author
Payman IB
committed
Refactor getOrdinalNumber function to improve variable naming and remove unnecessary console logs
1 parent ded405e commit a124398

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
function getOrdinalNumber(num) {
22
const suffixes = ["th", "st", "nd", "rd"];
3-
const v = num % 100;
4-
console.log(v);
5-
if (v >= 11 && v <= 13) {
3+
const date = num % 100;
4+
5+
if (date >= 11 && date <= 13) {
66
return num + "th";
77
}
8-
const suffix = suffixes[(v % 10)] || "th";
8+
const suffix = suffixes[(date % 10)] || "th";
99
return num + suffix;
1010
}
11-
console.log(getOrdinalNumber(52));
1211

1312
module.exports = getOrdinalNumber;

0 commit comments

Comments
 (0)