Skip to content

Sheffield| 26-Jan-ITP| Mona-Eltantawy | Sprint 3| Sprint 3 /practice TDD#1282

Open
Mona-Eltantawy wants to merge 3 commits intoCodeYourFuture:mainfrom
Mona-Eltantawy:PracticeTDD
Open

Sheffield| 26-Jan-ITP| Mona-Eltantawy | Sprint 3| Sprint 3 /practice TDD#1282
Mona-Eltantawy wants to merge 3 commits intoCodeYourFuture:mainfrom
Mona-Eltantawy:PracticeTDD

Conversation

@Mona-Eltantawy
Copy link
Copy Markdown

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

@Mona-Eltantawy Mona-Eltantawy added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

In this exercise, you were expected to practice "Test Driven Development" (TDD) by
first preparing the Jest tests and then implement the function to pass the tests.

In particular, in the .test.js files, explain what behavior the function should exhibit in the following format:

should <expected_behavior> when <condition>

so that someone reading the test can understand the requirement without reading another spec.

}

module.exports = countChar;
console.log(countChar('lol', 'l'));
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.

When you are done testing the function, don't forget to remove all debugging code to keep the code clean.

function getOrdinalNumber(num) {
return "1st";
function getOrdinalNumber(n) {
if (n % 100 >= 11 && n % 100 <= 13) return n + "th";
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.

Here is an alternative to express the code on line 2:

const lastTwoDigits = num % 100;

if  (lastTwoDigits >= 11 && lastTwoDigits <= 13) ...
  • More expressive
  • Avoid evaluating the same expression multiple times
  • (Cons) more code

Note: The difference might not be obvious in this example.

Comment on lines +1 to +5
function repeatStr(str, count) {
if( count >= 0 )
{return str.repeat (count)};
else { return 'invalid 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.

Indentation is off and some of the code is not consistently formatted.

Have you successfully assigned prettier as your default JS code formatter and enabled "Format on save/paste" on VSCode, as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?

@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 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants