London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Practice TDD#1046
London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Practice TDD#1046XiaoQuark wants to merge 9 commits intoCodeYourFuture:mainfrom
Conversation
| const str = "dog"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); |
There was a problem hiding this comment.
-
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
charis a certain non-alphabet character that has special meaning in regex.
- Currently your function does not work properly when
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Changes look good. Well done!
| const str = "dog"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); |
There was a problem hiding this comment.
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?
Learners, PR Template
Self checklist
Changelist
Completed TDD exercises using Jest
Wrote tests in files:
count.test.jsrepeat-str.test.jsget-ordinal-number.test.jsImplemented functions in files:
count.jsrepeat-str.jsget-ordinal-number.jsFollowed a test-first workflow.
Refactored some tests after implementation for clarity and readability.
Verified all tests pass using
npm test.