Skip to content

London| 26-ITP-Sep | Alan Mak | Sprint 2 | practice-tdd - #1714

Open
AlanGit-debug2604 wants to merge 6 commits into
CodeYourFuture:mainfrom
AlanGit-debug2604:Sprint2-TDD-from-main
Open

AlanGit-debug2604 wants to merge 6 commits into
CodeYourFuture:mainfrom
AlanGit-debug2604:Sprint2-TDD-from-main

Conversation

@AlanGit-debug2604

Copy link
Copy Markdown

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

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!

@AlanGit-debug2604 AlanGit-debug2604 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 15, 2026
@webmonch webmonch added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 20, 2026
@webmonch
webmonch self-requested a review October 20, 2026 22:16
expect(() => repeatStr(str, count)).toThrow(Error);
});

test ("should repeat the string count times", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you think of a better name for this test so it differs from others?

@AlanGit-debug2604 AlanGit-debug2604 Oct 20, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What about: test ("string should repeat itself for number of counts");

@webmonch

webmonch commented Oct 20, 2026 •

Copy link
Copy Markdown

In repeat-string.js , expression i++ and their variants , which one's more common? which one 's easier for reviewer in your view? Thanks!

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.

@webmonch

Copy link
Copy Markdown

Good job! Very clean solutions, thorough tests, and it's great to see from your commits that you really wrote the tests first.

@webmonch webmonch added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 20, 2026
Comment thread practice-tdd/count.js
Comment on lines +3 to +4
const count = stringOfCharacters.split(findCharacter).length - 1;
return count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Statement not consistently terminated by a semicolon. Why not use a formatter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Screenshot 2026-10-21 095436 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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +12 to +14
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
}

@cjyuan cjyuan Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any of them will do.

Suggestion: Use AI to explore "how to use comments in code?", and then clean up the comments.

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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants