Skip to content

Manchester| 26-ITP-Jan | Ofonime Edak | Sprint 3 | TDD#1226

Open
Ofonimeedak wants to merge 1 commit intoCodeYourFuture:mainfrom
Ofonimeedak:coursework/sprint-3-practice-tdd
Open

Manchester| 26-ITP-Jan | Ofonime Edak | Sprint 3 | TDD#1226
Ofonimeedak wants to merge 1 commit intoCodeYourFuture:mainfrom
Ofonimeedak:coursework/sprint-3-practice-tdd

Conversation

@Ofonimeedak
Copy link

@Ofonimeedak Ofonimeedak commented Mar 8, 2026

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 implemented all function and test cases using the Jest testing framework
I have run the test using npm run test
Sprint-3 TDD on testing of data using the Jest framework

@github-actions

This comment has been minimized.

@Ofonimeedak Ofonimeedak 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 8, 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 8, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@Ofonimeedak Ofonimeedak added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 8, 2026
@Theoreoluwa Theoreoluwa 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 12, 2026
Comment on lines +50 to +59

// case 5: expect number not included in the above case to return th
test("should return 'th' for numbers ending with 4, 5,6,7,8,9,0", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(5)).toEqual("5th");
expect(getOrdinalNumber(6)).toEqual("6th");
expect(getOrdinalNumber(7)).toEqual("7th");
expect(getOrdinalNumber(8)).toEqual("8th");
expect(getOrdinalNumber(9)).toEqual("9th");
expect(getOrdinalNumber(10)).toEqual("10th");

Choose a reason for hiding this comment

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

Your tests are fine. But there might be one edge case you are missing out on. You handled 11 and 13; is there one more key group you might have missed?

Comment on lines +2 to 17
const numStr = num.toString();
const numLength = numStr.length;
if (numStr[numLength - 2] === "1" && numStr[numLength - 1] === "1") {
return num + "th";
} else if (numStr[numLength - 1] === "1") {
return num + "st";
} else if (numStr[numLength - 2] === "1" && numStr[numLength - 1] === "3") {
return num + "th";
} else if (numStr[numLength - 1] === "3") {
return num + "rd";
} else if (numStr[numLength - 1] === "2") {
return num + "nd";
} else {
return num + "th";
}
}
Copy link

@Theoreoluwa Theoreoluwa Mar 12, 2026

Choose a reason for hiding this comment

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

There is a better arithmetic operator to be used for this function instead of string indexing. This ensures all edge cases are handled in your tests. To ensure code clarity and to avoid string manipulation

Copy link

@Theoreoluwa Theoreoluwa left a comment

Choose a reason for hiding this comment

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

Great job so far Edak. Kindly look at the comments made to improve the work done. Well done!

@Theoreoluwa Theoreoluwa 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 12, 2026
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