Repository navigation
London| 26-ITP-Sep | Alan Mak | Sprint 2 | practice-tdd - #1714
AlanGit-debug2604 wants to merge 6 commits into
Conversation
…ingle occurrences, and edge cases
…th 1, 2, 3, 11, 12, 13, and all other numbers
… in 1, 2, and 3, but excluding 11, 12, and 13 respectively
| expect(() => repeatStr(str, count)).toThrow(Error); | ||
| }); | ||
|
|
||
| test ("should repeat the string count times", () => { |
There was a problem hiding this comment.
Can you think of a better name for this test so it differs from others?
There was a problem hiding this comment.
What about: test ("string should repeat itself for number of counts");
Good question! i++ is by far the most common form in a for loop, so it's what most reviewers will expect to see there. Though i += 1 is also a solid option. Others are a bit less common. |
|
Good job! Very clean solutions, thorough tests, and it's great to see from your commits that you really wrote the tests first. |
| const count = stringOfCharacters.split(findCharacter).length - 1; | ||
| return count |
There was a problem hiding this comment.
Statement not consistently terminated by a semicolon. Why not use a formatter?
There was a problem hiding this comment.
Thanks for pointing this out. This seems weird to me because I have turned on Prettier; I chose formatting on save in setting. Just now I also double-checked bar on bottom right Prettier has been in place. I will take a look of this. In the meantime, is there situation where Prettier (or formatter) doesn't apply (e.g. for specific language only), and require further configuration to keep it on?
There was a problem hiding this comment.
Prettier only support certain languages. For example, I know it does not support Python.
Here are two possible conditions I know from experience that Prettier may not work on JS code:
- The code has a syntax error (not your case)
- You have more than one VS Code extensions that can format JS code. If this is the case, when you manually select "Format document" on JS code, VS Code may prompt you to select a default formatter for JS code and you could then select Prettier as your formatter. After that, "Format on save" should work.
| for (let i = 0; i < count; i++) { // i++ is i=i+1, i+=1, i=i+1, all are valid | ||
| result = result + str; //result += str; is also valid | ||
| } |
There was a problem hiding this comment.
Any of them will do.
Suggestion: Use AI to explore "how to use comments in code?", and then clean up the comments.
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Wrote jest test files: Count ; Repeat-str ; Get-ordinal. Then followed each test file by their respective implementation file.
Questions
In
repeat-string.js, expression i++ and their variants , which one's more common? which one 's easier for reviewer in your view? Thanks!