London | ITP-Jan-26 | Abdul Moiz | Sprint 3 | Practice TDD#917
Open
A-Moiz wants to merge 2 commits intoCodeYourFuture:mainfrom
Open
London | ITP-Jan-26 | Abdul Moiz | Sprint 3 | Practice TDD#917A-Moiz wants to merge 2 commits intoCodeYourFuture:mainfrom
A-Moiz wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Feb 12, 2026
Comment on lines
3
to
4
| let lastDigit = stringNum[stringNum.length - 1]; | ||
| if (lastDigit === "1" && num % 100 !== 11) { |
Contributor
There was a problem hiding this comment.
- Why not also store the last two digits in a variable first?
- Why use different data type to represent the last digit and the last two digits?
- For variables not need to be reassigned a value, it is a better practice to declare them using
const.
Author
There was a problem hiding this comment.
Resolved function by storing last 2 digit.
Comment on lines
+41
to
+43
| test("should append 'th' for all other numbers", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); |
Contributor
There was a problem hiding this comment.
Could consider testing more samples in this category to make the test more comprehensive.
| } else { | ||
| throw new Error("Count must be a non-negative integer"); | ||
| } | ||
| return ""; |
Contributor
There was a problem hiding this comment.
The code on line 9 is unreachable (we call them "dead code").
Could consider not using else because of the return statements inside the if-blocks.
Contributor
|
Changes look good. Well done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Completed all exercises in Practice TDD directory
Questions
N/A