Skip to content

Conversation

@Mahtem
Copy link

@Mahtem Mahtem commented Nov 12, 2025

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

Functions implemented and tested using possible cases.

Questions

Questions will be asked in Slack.

@Mahtem Mahtem added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Nov 12, 2025
Comment on lines 2 to 17
if (typeof stringOfCharacters!= "string") {
throw new Error("Input should be a string");
}
if (typeof findCharacter !== "string" || findCharacter.length != 1){
throw new Error ("Input must be a single character");
}

let count = 0;
for(let char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}
return count;

}
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 improve the indentation?

Copy link
Author

Choose a reason for hiding this comment

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

Can you improve the indentation?

Thank you, I have improved the indentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Test is quite comprehensive.

Can your function pass all the tests?

Copy link
Author

Choose a reason for hiding this comment

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

Test is quite comprehensive.

Can your function pass all the tests?

I have added, some more tests and the function passed all tests.

Comment on lines 13 to 30
test("should return correct ordinals for 1, 2, 3, 4, 21, 22, 23, 24", () => {
expect(getOrdinalNumber(1)).toEqual("1st");
expect(getOrdinalNumber(2)).toEqual("2nd");
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(22)).toEqual("22nd");
expect(getOrdinalNumber(23)).toEqual("23rd");
expect(getOrdinalNumber(24)).toEqual("24th");
});

// Case 2: Exceptions 11, 12, 13
test("should handle exceptions 11, 12, 13 correctly", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
expect(getOrdinalNumber(111)).toEqual("111th");
});
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 grouping test values by their characteristics. For examples,

  • All numbers that end in 1 (but not in 11).
  • Repeat the above for 2 and 3.
  • All numbers that end in 11, 12, or 13.
  • All numbers that end in 0, 4-9.
    (In addition to invalid cases).

This approach could better cover all possible cases and give more specific message when a test fails.

Copy link
Author

Choose a reason for hiding this comment

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

Could consider grouping test values by their characteristics. For examples,

* All numbers that end in 1 (but not in 11).

* Repeat the above for 2 and 3.

* All numbers that end in 11, 12, or 13.

* All numbers that end in 0, 4-9.
  (In addition to invalid cases).

This approach could better cover all possible cases and give more specific message when a test fails.

Thank you, I have tried to group them with exceptions.

@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 Nov 15, 2025
@Mahtem Mahtem added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 21, 2025
Copy link
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.

Changes look good.

Comment on lines 2 to 17
if (typeof stringOfCharacters!= "string") {
throw new Error("Input should be a string");
}
if (typeof findCharacter !== "string" || findCharacter.length != 1){
throw new Error ("Input must be a single character");
}

let count = 0;

for(let char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}
return count;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Code is still not properly indented.

You can use VSCode's "Format document" feature (after installing the "prettier" extension) to auto-format JS code.

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan, I have used prettier to format the document. Thank you.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 21, 2025
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 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants