Skip to content

London | 26-ITP-May | Dagim Daniel | Sprint 3 | Practice-tdd#1480

Open
Dagim-Daniel wants to merge 1 commit into
CodeYourFuture:mainfrom
Dagim-Daniel:coursework/sprint-3-practice-tdd
Open

London | 26-ITP-May | Dagim Daniel | Sprint 3 | Practice-tdd#1480
Dagim-Daniel wants to merge 1 commit into
CodeYourFuture:mainfrom
Dagim-Daniel:coursework/sprint-3-practice-tdd

Conversation

@Dagim-Daniel

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

Changelist

Sprint 3 all tasks under practice-tdd has been done.

@Dagim-Daniel Dagim-Daniel added 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 Jul 7, 2026
@tiakavousi tiakavousi 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 Jul 8, 2026
return 5
let count = 0;
str = stringOfCharacters
char = findCharacter

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great function, this works perfectly!
Quick question on lines 3 and 4:
str and char are declared without any keywords. What happens to variables in JavaScript when we don't use let or const?

also since we already have stringOfCharacters and findCharacter passed into the function as arguments, do we need to assign them to new variables?
What would happen if you used the arguments directly in your loop?

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.

we don't need to assign them to new variables, i just used it to help me with the test cases. -

const count = countChar(str, char);
expect(count).toEqual(2);
});
// Scenario: No Occurrences

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have the setup comments for a 'No Occurrences' scenario, but the test block is missing. maybe you've forgotten to write this one?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job on these tests!

Since you are already thinking about edge cases like that, what are some other tricky inputs we might want to test for? (For example: what happens if someone passes in an empty string, or wants to count empty spaces?

function getOrdinalNumber(num) {
return "1st";
const s = ["th", "st", "nd", "rd"];
const lastDigits = num % 100;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job on the logic
Just a quick formatting note: the indentations here in this file and the others can be improved.
Have you considered setting up a formatter like Prettier in your IDE to handle these automatically?

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.

yeah i do install the prettier extension, just failed to make it auto-format on save. thanks i will fix it.

expect(repeatedStr).toEqual("ITPITPITPITPITP");
});

// Case: handle count of 1:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm assuming these are some leftover comments that you can safely delete since you already wrote an awesome test for count = 1 up above!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Imagine one of these tests fails and you're reading that red output in the console. Since all the descriptions are identical right now (both here and in count.test.js), how could we update the test names to be more self-explanatory so you immediately know exactly what broke?

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.

you are right this could be fix, maybe by making clear test description.

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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants