Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237
Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237mshayriyesaricicek wants to merge 17 commits intoCodeYourFuture:mainfrom
Conversation
| expect(countChar("aaaaa", 'b")).toEqual(5); | ||
| expect(countChar("blind", 'a)).toEqual(0); | ||
| expect(countChar("blood", 'o")).toEqual(2); | ||
| expect(countChar("bbbrf", 'b")).toEqual(3); | ||
| expect(countChar("ooooa", 'o")).toEqual(4); |
There was a problem hiding this comment.
I noticed I had syntax errors with the quotes and when I changed it then saved the file Prettier changed the indentation.
There was a problem hiding this comment.
Note: In VSCode, when a JS file ha syntax errors, its name is usually shown in red color in the Explorer view.
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good.
I have a few more suggestions.
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| // Check if input is a number | ||
| if (!Number.isInteger(num) || !Number.isFinite(num) || num <= 0) { |
There was a problem hiding this comment.
-
Number.isFinite()is also redundant -
Good thinking about rejecting negative numbers. In some context such as in math, the ordinal number of
0is0th.
| // For numbers that don't end in 1 (not11), 2 and 3 | ||
| // the function should return a string by appending "th" to the number. | ||
|
|
||
| test("should append 'th' if number is 11, 12 or 13 or does not end in 1, 2 or 3",() => { |
There was a problem hiding this comment.
This group should also include numbers ending with 11, 12, or 13 (not just that three numbers).
A direct listing of all the trailing digits in the description might be easier to read:
should append 'th' for numbers ending with 0, 4, 5, 6, 7, 8, 9, 11, 12, or 13
|
Changes look good. Well done. |
Self checklist
Changelist
This PR is to practice writing tests before writing functions