Skip to content

Scotland | ITP JAN-2026 | Tuan Nguyen | Sprint 3 | 2- Practice-tdd#1258

Open
Jacknguyen4438 wants to merge 3 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Jest-test-case-sprint-3B
Open

Scotland | ITP JAN-2026 | Tuan Nguyen | Sprint 3 | 2- Practice-tdd#1258
Jacknguyen4438 wants to merge 3 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Jest-test-case-sprint-3B

Conversation

@Jacknguyen4438
Copy link

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

Changelist

I have done practice and fully understand how to write a test for both normal JS and Jest test.

Questions

No Question.

@Jacknguyen4438 Jacknguyen4438 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 13, 2026
Comment on lines +8 to +10
if (findCharacters.length < 1) {
throw new Error("findCharacters must be a single character");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is findCharacters allowed to be more than one characters?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider testing a few more samples in this script - higher chance to detect bugs in code.

The original specification did not clearly state whether the character match should be case-sensitive.
Most people would probably assume that it is, but to demonstrate our understanding or clarify the assumption we made,
we could add test cases to convey this. For examples,

  • A case to show that the match is case sensitive
  • A case to show that the function is expected to work also for non-alphabets

Comment on lines +10 to +18
if(num % 100 === 11 ||num % 100 === 12 || num % 100 === 13 ){
return `${num}th`;
}
switch( true ){
case num % 10 === 1 : return `${num}st`;
case num % 10 === 2 : return `${num}nd`;
case num % 10 === 3 : return `${num}rd`;
default : return `${num}th`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you look up the pros and cons between these two styles of expressing the code?

  if(num % 100 === 11 ||num % 100 === 12 || num % 100 === 13 ){
  const lastTwoDigits = num % 100;
  if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13 ) {

?

}

// This allow float number to be round into it nearest integer.
num = Math.round(num);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you decide to round the numbers with decimal places? Why not reject them?

// Case 5: All other numbers
// When the number does not end with 1, 2, or 3,
// Then the function should append "th".
test("should append 'th' for all other numbers", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

When a test fails with the message "... all other numbers", it may be unclear what "other numbers" actually refers to.
Can you revise the test description to make it more informative?

Comment on lines +6 to +9
switch (true){
case repeatCount === 0 : return "";
default: return fullString.repeat(repeatCount) ;
};
Copy link
Contributor

@cjyuan cjyuan Mar 14, 2026

Choose a reason for hiding this comment

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

What do you think about this writing style?

if (repeatCount === 0) return "":

return fullString.repeat(repeatCount);

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 14, 2026
@Jacknguyen4438
Copy link
Author

@cjyuan Hello thank you for the review, I see there are many part that need to be fix and improve. I will check all 5 part that you would like me to explain and fix each of them. When I finish I will mention you again to ask for a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants