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 11c8346 commit e947150Copy full SHA for e947150
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -1,11 +1,11 @@
1
function getOrdinalNumber(num) {
2
// Check if input is a number
3
- if (typeof num !== "number" || isNaN(num)) || !Number.isInteger(num) || !Number.isFinite(num)) {
+ if (!Number.isInteger(num) || !Number.isFinite(num) || num <= 0) {
4
throw new Error("Input must be a valid number");
5
}
6
7
const lastnum = num % 10; // checks what last number is
8
- const last2num = % 100; // checks what last two numbers are, needed to check for 11
+ const last2num = num % 100; // checks what last two numbers are, needed to check for 11
9
10
if (last2num === 11 || last2num === 12 || last2num === 13) {
11
return num + "th";
0 commit comments