Skip to content

London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Practice TDD#1046

Open
XiaoQuark wants to merge 9 commits intoCodeYourFuture:mainfrom
XiaoQuark:practice-tdd/sprint-3
Open

London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Practice TDD#1046
XiaoQuark wants to merge 9 commits intoCodeYourFuture:mainfrom
XiaoQuark:practice-tdd/sprint-3

Conversation

@XiaoQuark
Copy link

Learners, PR Template

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

Changelist

  • Completed TDD exercises using Jest

    • Wrote tests in files:

      • count.test.js
      • repeat-str.test.js
      • get-ordinal-number.test.js
    • Implemented functions in files:

      • count.js
      • repeat-str.js
      • get-ordinal-number.js
  • Followed a test-first workflow.

  • Refactored some tests after implementation for clarity and readability.

  • Verified all tests pass using npm test.

@XiaoQuark XiaoQuark added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 24, 2026
Comment on lines +27 to +30
const str = "dog";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(0);
Copy link
Contributor

@cjyuan cjyuan Mar 6, 2026

Choose a reason for hiding this comment

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

  • Could consider testing more samples.

  • Could consider test these cases:

    • A case to show that the match is case sensitive
    • A case to show that the function should work also for non-alphabets
      • Currently your function does not work properly when char is a certain non-alphabet character that has special meaning in regex.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you CJ, I reviewed your comment, and I think I'm now covering all the cases you mentioned.
This was actually really fun to work on. I've been learning a lot about working with regex.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to work ok now.

I am glad you learned something more about regex.

It is ok to use this approach in this course but I wouldn't recommend it in practice for such a task.
Can you find out (maybe from AI) the pros and cons using this approach to count characters?

@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 Mar 6, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look good. Well done!

Comment on lines +27 to +30
const str = "dog";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to work ok now.

I am glad you learned something more about regex.

It is ok to use this approach in this course but I wouldn't recommend it in practice for such a task.
Can you find out (maybe from AI) the pros and cons using this approach to count characters?

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants