Skip to content

Conversation

@enjoy15
Copy link

@enjoy15 enjoy15 commented Oct 15, 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

-Completed all excercises in Sprint-3

@enjoy15 enjoy15 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 Oct 15, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Oct 25, 2025

Please hold on creating new PRs for Sprint-3 exercise. I am asking for permission to accept also Sprint-3 exercise submitted in one PR.

On separate note, why set the branch name to coursework/sprint-3-implement-and-rewrite/implement/1-get-angle-type?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 25, 2025
@enjoy15
Copy link
Author

enjoy15 commented Oct 25, 2025

Please hold on creating new PRs for Sprint-3 exercise. I am asking for permission to accept also Sprint-3 exercise submitted in one PR.

On separate note, why set the branch name to coursework/sprint-3-implement-and-rewrite/implement/1-get-angle-type?

Thanks for the feedback! I initially named the branch that way because I thought a separate PR was required for each file. Later, I realized that wasn’t necessary, but I continued working on the same branch. I wasn’t sure how to rename the branch, so I decided to keep it as is.

@cjyuan
Copy link
Contributor

cjyuan commented Oct 25, 2025

We could rename a branch on GitHub.
However, if we have opened a PR from a branch, renaming the branch will close the corresponding PR.

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.

Let's continue to work on this branch. Should you need to resubmit your work in separate PRs, you can just submit the improved code.

Regarding the PR description, the "Changelist" header is not formatted properly in Markdown syntax.

return "Acute angle";
}
// Then keep going for the other cases, one at a time.
if (angle > 90 && angle < 180) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checking angle > 90 is optional because previous if-statements (together with the return statements) can guarantee angle is always more than 90.

Copy link
Author

Choose a reason for hiding this comment

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

Removed checking angle > 90

Comment on lines 18 to 19
const numValue = parseInt(rank, 10);
if (numValue >= 2 && numValue <= 10) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.1", or "0002".

Does your function return the value you expected from each of the following function calls?

getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");

Copy link
Author

Choose a reason for hiding this comment

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

With the current function
getCardValue("0x02♠") → undefined
parseInt("0x02", 10) stops at "x" and returns 0, which is outside the 2–10 range, so function returns undefined.

getCardValue("2.1♠") → 2
parseInt("2.1", 10) parses up to the dot and returns 2, which is in the 2–10 range, so function returns 2.

getCardValue("0002♠") → 2
parseInt("0002", 10) returns 2, so the function returns 2.

I changed the code so "0x02" to be interpreted as the JavaScript numeric literal 0x02 (i.e. 2), and reject non-integer ranks like "2.1", by changing the parsing to use Number() and check integerness.### ###

Comment on lines 15 to 17
test("should return false for a negative fraction", () => {
expect(isProperFraction(-2, 3)).toEqual(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

In math, -2/3 is considered a proper fraction.

Copy link
Author

Choose a reason for hiding this comment

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

change the test result to true for-2/3.

Comment on lines +11 to +14
test("should return numeric value for number cards (2-10)", () => {
const fiveofHearts = getCardValue("5♥");
expect(fiveofHearts).toEqual(5);
});
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 testing more sample values in each category (to make the test more comprehensive), especially the boundary cases such as "2♥" and "10♥".

Copy link
Author

Choose a reason for hiding this comment

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

Added more tests, especially the boundary cases such as "2♥" and "10♥."

Comment on lines 19 to 21
test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

To ensure thorough testing, we need broad scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories. Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.

For example, we can prepare a test for numbers 2, 22, 132, etc. as

test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
    expect( getOrdinalNumber(2) ).toEqual("2nd");
    expect( getOrdinalNumber(22) ).toEqual("22nd");
    expect( getOrdinalNumber(132) ).toEqual("132nd");
});

Copy link
Author

Choose a reason for hiding this comment

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

Tests are now grouped together.

@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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 25, 2025
@enjoy15
Copy link
Author

enjoy15 commented Oct 25, 2025

Regarding the PR description, the "Changelist" header is not formatted properly in Markdown syntax.

Changelist updated. Thank you.

@enjoy15 enjoy15 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 25, 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. I have few more suggestions.

Comment on lines 18 to 21
const numeric = Number(rank);
if (Number.isInteger(numeric) && numeric >= 2 && numeric <= 10) {
return numeric;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. To see some examples, you can request AI to show you all forms of string values in JS, when converted to a number, equals to an integer 2.

Do you want these kinds of strings be recognized as valid ranks?

Hint; Validate the string value before converting its value.

Copy link
Author

Choose a reason for hiding this comment

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

Change the code to validate the string value before converting its value.

Comment on lines 15 to 17
test("should return false for a negative fraction", () => {
expect(isProperFraction(-2, 3)).toEqual(false);
expect(isProperFraction(-2, 3)).toEqual(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

The test description does not match what is being tested.

You could consider "function call with negative parameters" as one category and test some samples in this category,
or you could introduce two tests, "should return false for negative improper fraction", "should return true for negative proper fraction".

Copy link
Author

Choose a reason for hiding this comment

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

The comments and tests for negative fractions are now clarified and split into two categories: negative proper fractions (should return true) and negative improper fractions (should return false), with representative samples for each.

Comment on lines 38 to 44
// All other numbers: should append 'th'
test("append 'th' to all other numbers", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(10)).toEqual("10th");
expect(getOrdinalNumber(14)).toEqual("14th");
expect(getOrdinalNumber(0)).toEqual("0th");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

A more informative description could be "... to numbers ending in 0, 4-9."

Copy link
Author

Choose a reason for hiding this comment

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

Comment updated. Thank you.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 25, 2025
@enjoy15 enjoy15 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants