Skip to content

London|26-ITP-Sep|Abdennour Hachemi|Sprint 2 |Practice TDD - #1701

Open
AbdennourHachemi wants to merge 19 commits into
CodeYourFuture:mainfrom
AbdennourHachemi:new/coursework/sprint-3-practice-tdd
Open

AbdennourHachemi wants to merge 19 commits into
CodeYourFuture:mainfrom
AbdennourHachemi:new/coursework/sprint-3-practice-tdd

Conversation

@AbdennourHachemi

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1060

@AbdennourHachemi AbdennourHachemi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 13, 2026
@valentina-starr1

Copy link
Copy Markdown

Thanks for working on this..The core exercise implementations look solid overall, but i can see one blocking issue regarding version control configuration that needs to be addressed before merging.

  1. .gitignore Fix (Blocking)
    practice-tdd/.gitignore: Please remove package.json and package-lock.json from .gitignore. These files must be tracked in the repository to maintain consistent dependencies, scripts, and build environments across machines.

  2. Actionable Improvements & Refactoring
    practice-tdd/repeat-str.js: Returning an error string ("Error! negative counts...") on negative inputs differs from idiomatic JS and the exercise intent. Please throw an Error instead (e.g., throw new Error(...)) and update repeat-str.test.js to use expect(() => ...).toThrow().

practice-tdd/get-ordinal-number.js: The regex logic works, but switching to numeric modulo operations (num % 100 and num % 10) would make the branching much clearer and easier to maintain.

practice-tdd/get-ordinal-number.test.js: Consider adding test cases for 3-digit teen exceptions (e.g., 111, 112, 113) to ensure the suffix rules scale properly.

practice-tdd/count.test.js: Minor nit - @jest/globals imports aren't needed since Jest provides them globally, and there's a small typo in numberOfOcurrence (numberOfOccurrence).

Once package.json and package-lock.json are un-ignored and the error-throwing behavior is updated, this should be good to go.

@AbdennourHachemi

Copy link
Copy Markdown
Author

Thanks @valentina , i have fixed my code according to your review . please have a look again and see if anything else needs correction.

@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 20, 2026

@hey-hammad hey-hammad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great implementation overall, a couple minor issues needs attention. Thanks

Comment thread practice-tdd/.gitignore Outdated
@@ -0,0 +1,2 @@
node_modules

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a .gitignore file already exist in the root of the repo which is enough.

expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(131)).toEqual("131st");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test case handling the special cases like 11,12,13,101 & 103 will make this suit more robust.

@hey-hammad hey-hammad added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 20, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation is correct.

Some of the tests could be refined.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could consider testing multiple samples in each test category - higher chance to detect bugs in code.

  • Empty string is often a good edge case to test.

  • When a specification is ambiguous, programmers may need to make reasonable assumptions based on their understanding of the requirements. In this case, the original specification did not explicitly state whether character matching should be case-sensitive. Although most people would likely assume that it is, adding test cases can help document this assumption and make our interpretation of the specification explicit.

    Similarly, we should consider adding tests for any other assumptions made during implementation to clarify the intended behavior and ensure these assumptions are consistently understood and validated.

// Case 4: Numbers ending with any other number (but not 1,2 or 3)
// When the number ends with 4,5,6 ,7 ,8 or 9 ,
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for numbers ending with 4,5,6 ,7 ,8 or 9 ", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all "other digits" covered in this category?

Comment thread practice-tdd/get-ordinal-number.test.js Outdated
Comment on lines +53 to +55
// When the number ends with ,(111, 112,113)
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for numbers ending with ", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The test description seems incomplete.

  • When a comment repeats information already conveyed in the test description, consider removing it to avoid redundancy.

Comment thread practice-tdd/repeat-str.test.js Outdated
@AbdennourHachemi AbdennourHachemi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 26, 2026
Comment on lines +48 to +52
test("should append 'th' for numbers in 100's ending with 11, 12 , 13", () => {
expect(getOrdinalNumber(111)).toEqual("111th");
expect(getOrdinalNumber(112)).toEqual("112th");
expect(getOrdinalNumber(113)).toEqual("113th");
});

@cjyuan cjyuan Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why limit the cases to numbers in the 100's?

Comment on lines +54 to +62
// Case 6:A test case handling the special cases like 11,12,13,101 & 103

test("should append 'th' for numbers for 11,12,13 and 'st' for 101 and 'rd' for 103", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
expect(getOrdinalNumber(101)).toEqual("101st");
expect(getOrdinalNumber(103)).toEqual("103rd");
});

@cjyuan cjyuan Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these five numbers considered special cases? What do you mean by "special"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests in this script do not yet covered all valid cases.

Comment on lines +2 to +5
//handle a non number inputs
if (!num) {
return "";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by a non-number? !num is not a proper way to check if num is a number or not.

Note: You could assume the parameter is always a number in this exercise.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants