Skip to content

London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 3 | practice tdd#1265

Open
djebsoft wants to merge 17 commits intoCodeYourFuture:mainfrom
djebsoft:sprint-3/practice-TDD
Open

London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 3 | practice tdd#1265
djebsoft wants to merge 17 commits intoCodeYourFuture:mainfrom
djebsoft:sprint-3/practice-TDD

Conversation

@djebsoft
Copy link

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

buit up my program test then wrote the code that will make them pass.

Questions

@djebsoft djebsoft added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 14, 2026
@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 15, 2026
@mshayriyesaricicek mshayriyesaricicek added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 15, 2026
@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 16, 2026
@djebsoft djebsoft added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
return "1st";
let remainder1 = num % 10;
let remainder2 = num % 100;
if (remainder1 === 1 && remainder2 !== 11) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Best practice is to give variables descriptive (self-explanatory) names. Can you rename these two variables to make the code more readable.

let remainder1 = num % 10;
let remainder2 = num % 100;
if (remainder1 === 1 && remainder2 !== 11) {
// we also can use if (num[-1]===1 && num.slice(-2)!==11)
Copy link
Contributor

@cjyuan cjyuan Mar 16, 2026

Choose a reason for hiding this comment

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

Note: This expression (in the comment) is comparing a string to a number.

Copy link
Author

Choose a reason for hiding this comment

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

fixed the comparison

// When the number does not end with 1, 2, or 3
// Then the function should return a string by appending "th" to the number.

test("should append 'th' for all other numbers", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test description is what Jest output in the test report. It's better to replace "all other numbers" by the detailed condition described on line 50.

Copy link
Author

Choose a reason for hiding this comment

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

replaced

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@djebsoft djebsoft added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
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. Well done.

let lastDigit = num % 10;
let lastTwoDigits = num % 100;
if (lastDigit === 1 && lastTwoDigits !== 11) {
// we also can use if (num[-1]==="1" && num.slice(-2)!=="11")
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: num[-1] is not the syntax to extract the last character in JavaScript. It will be evaluated to undefined.

Use .at(-1) or .slice(-1) instead.

Copy link
Author

Choose a reason for hiding this comment

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

I changed it to .slice() instead of index to extract the last character
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 Mar 16, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants