Skip to content

Manchester | 26-ITP-May | Yee Man Tsang | Sprint 3 | 2-practice-tdd - #1507

Open
lintsang wants to merge 2 commits into
CodeYourFuture:mainfrom
lintsang:2-practice-tdd
Open

Manchester | 26-ITP-May | Yee Man Tsang | Sprint 3 | 2-practice-tdd#1507
lintsang wants to merge 2 commits into
CodeYourFuture:mainfrom
lintsang:2-practice-tdd

Conversation

@lintsang

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

Finished all exercises in 2-practice-tdd folder

@Liam310 Liam310 added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jul 14, 2026
@Liam310

Liam310 commented Jul 14, 2026

Copy link
Copy Markdown

Don't forget to add the Needs review label to your coursework Lin otherwise it might get missed by reviewers!

(I've picked this up today but bear it in mind for future!)

Comment thread Sprint-3/2-practice-tdd/count.test.js Outdated
Comment thread Sprint-3/2-practice-tdd/count.js
Comment on lines +4 to +40
if (String(num).length > 1) {
//check if the number has more than 1 digit
onesDigit = Number(String(num).slice(-1)); //extract the figure at the tens digit, and convert it into a number.
const tensDigit = Number(String(num).slice(-2, -1)); //extract the figure at the tens digit, and convert it into a number.

if (onesDigit == 1) {
if (tensDigit == 1) {
return num + "th";
} else {
return num + "st";
}
} else if (onesDigit == 2) {
if (tensDigit == 1) {
return num + "th";
}
return num + "nd";
} else if (onesDigit == 3) {
if (tensDigit == 1) {
return num + "th";
}
return num + "rd";
} else {
("th");
}
} else if (String(num).length == 1) {
onesDigit = Number(String(num)[0]); //extract the figure at the tens digit, and convert it into a number.
if (onesDigit == 1) {
return num + "st";
console.log("Yeah youre in");
} else if (onesDigit == 2) {
return num + "nd";
} else if (onesDigit == 3) {
return num + "rd";
} else {
return num + "th";
}
}

@Liam310 Liam310 Jul 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a mostly working solution, but with a lot of nested if statements it can be quite hard to follow the logic of it.

A few things to consider:

  • You repeat the same if (tensDigit == 1) { return num + "th" } line, which suggests if the tens digit of the number is 1, you're always doing the same thing. How you might you simplify this so you only need to perform that check once?
  • On line 25 you have an else statement that doesn't contain any logic. What should that statement be doing? Why wasn't it caught by the tests?
  • The logic you have for numbers whose "length" is 1 is very similar to the logic you have for numbers whose "length" is more than 1. You could definitely make this less repetitive!
  • In a lot of places you have used == instead of === - I asked you in a previous submission what the difference was and what would be better - same question applies here!
  • You've got a leftover console.log on line 32 - get rid!

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.

Thanks for guiding me on this problem. I am having some insights for how to make this kind of statement in the future.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is so much better Lin! I hope you are happy with this improvement 😄

Comment thread Sprint-3/2-practice-tdd/get-ordinal-number.test.js
Comment thread Sprint-3/2-practice-tdd/repeat-str.js Outdated
Comment thread Sprint-3/2-practice-tdd/repeat-str.test.js Outdated
@Liam310 Liam310 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 Jul 14, 2026
@lintsang lintsang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 24, 2026
@Liam310 Liam310 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 Jul 28, 2026
@Liam310

Liam310 commented Jul 28, 2026

Copy link
Copy Markdown

@lintsang Really nice improvements here Lin - I have no further comments so happy to mark as Complete ✅

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.

2 participants