Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
hackertainment
left a comment
There was a problem hiding this comment.
The code generally looks good to me. Please keep it up.
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(5); | ||
| }); |
There was a problem hiding this comment.
This is a special case of str where it is all the char to count. Would it still count correctly if the char just exists in some part of the str?
There was a problem hiding this comment.
“Thanks for the suggestion! I added a test that counts 'l' in 'hello' and expects 2.”
| test("should return 0 when the character does not occur", () => { | ||
| const str = "hello"; | ||
| const char = "z"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
There is a special str that would give 0 anyway. Please add that test case as well. Thank you.
There was a problem hiding this comment.
“Thanks! I added a test using an empty string as the input; it correctly returns 0.”
There was a problem hiding this comment.
Your test cases are correct. Just for you to think a little bit more, besides const str = "hello", what special string should also be added to each of the test cases?
There was a problem hiding this comment.
“Thanks for pointing that out! I added empty-string checks to each repeatStr test case.”
ffb9851 to
8a70a6d
Compare
|
Wee done to all the additional test cases. Congratulation, you have completed this PR successfully. |
Self checklist
Task code
CYF-1060
Changelist
Completed TDD exercises using Jest. Implemented the required functions and wrote tests to cover the expected behaviour and edge cases