Skip to content

London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | coursework practice tdd#1271

Open
Zadri415 wants to merge 5 commits intoCodeYourFuture:mainfrom
Zadri415:coursework/sprint-3-practice-tdd
Open

London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | coursework practice tdd#1271
Zadri415 wants to merge 5 commits intoCodeYourFuture:mainfrom
Zadri415:coursework/sprint-3-practice-tdd

Conversation

@Zadri415
Copy link

@Zadri415 Zadri415 commented Mar 16, 2026

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

Completed the Sprint 3 practice TDD tasks

  • Wrote tests before implementation
  • Feature implemented to pass tests

@github-actions

This comment has been minimized.

@Zadri415 Zadri415 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. labels Mar 16, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Zadri415 Zadri415 changed the title London | 26-ITP-Jan | Sprint 3 | Coursework/sprint 3 practice tdd London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | Coursework/sprint 3 practice tdd Mar 16, 2026
@Zadri415 Zadri415 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@Zadri415 Zadri415 changed the title London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | Coursework/sprint 3 practice tdd London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | coursework practice tdd Mar 16, 2026
@ykamal ykamal 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 Mar 16, 2026
// implement a function countChar that counts the number of times a character occurs in a string
const countChar = require("./count");
const countChar = require("./count");{
}
Copy link

Choose a reason for hiding this comment

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

Do you think there is a syntax issue here? How would you ensure your IDE can catch such issues?
Worth checking: file formatting with Priettier

Copy link

@ykamal ykamal left a comment

Choose a reason for hiding this comment

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

I think overall this is good. Good job so far 👍

There are a few things you should look into:

  1. For counting the occurrences of a character in a string, you could use something like .split() and do a count on the returning array. The benefit is that it's cleaner and probably more performant.
  2. This function could also fail if the string provided doesn't match certain criteria. As a developer, you should account for those. Details in the comment associated.
  3. There is a syntax issue in the count.test.js file. Details in the comment associated.
  4. getOrdinalNumber could fail if the number is not as expected. Details in the comment associated.

@@ -1,5 +1,13 @@
function countChar(stringOfCharacters, findCharacter) {
Copy link

@ykamal ykamal Mar 16, 2026

Choose a reason for hiding this comment

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

What if the string stringOfCharacters was not provided at all? What if it's undefined, or null?
You should take into account where your code could produce an error and account for that.
How do you think you'd account for those scenarios?

@@ -1,5 +1,18 @@
function getOrdinalNumber(num) {
Copy link

Choose a reason for hiding this comment

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

Since it's a number, it could be negative or a float (decimal).
Does this function assume that the number is always going to be a positive whole number?
How would you account for those scenarios?

@ykamal ykamal added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 16, 2026
// Case 5: ALL other numbers
// When the number does not end with 1, 2, 3, 11, 12, or 13,
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for all other numbers", () => {

Choose a reason for hiding this comment

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

Might be worth adjusting this test to be more specific, as 'all other numbers' failing won't tell us which numbers they are? Other tests look great!

if (lastDigits >= 11 && lastDigits <= 13) {
return num + "th";
}
switch (lastDigits % 10) {

Choose a reason for hiding this comment

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

Nice use of a switch statement here!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants