Repository navigation
Conversation
…ing the task again and see I must not use .repeat.... here we go again then ^_^
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework. Please keep it up.
There was a problem hiding this comment.
Your code is correct. Just wondering what is the advantage of using this approach over other implementations? Thank you.
| 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?
| test("should count 0 with no occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "b"; | ||
| 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.
| if (11 <= Number(numString.slice(-2)) && 19 >= Number(numString.slice(-2))) { | ||
| return numString + "th"; | ||
| } else if ( | ||
| -11 >= Number(numString.slice(-2)) && | ||
| -19 <= Number(numString.slice(-2)) | ||
| ) { |
There was a problem hiding this comment.
Please be aware of the consistency of code formatting - while the first if using one line for the conditions but the second if using multiple lines for the conditions. I personally would prefer one line which may usually be easier to read, unless explicitly specified by coding standard in a business environment.
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?
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Completed the tasks by doing tdd to the best of my ability.