Skip to content

Conversation

@Iswanna
Copy link

@Iswanna Iswanna commented Oct 23, 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

This pull request involves modifications to two directories:

Implement directory: I added assertions using console.assert and built the program case by case.

Rewrite-tests-with-Jest directory: I rewrote the existing test cases using Jest and ran npm test to verify the implementation of the getCardValue function.

Questions

Hi. Please could you review my PR? I’d really appreciate your feedback?

@Iswanna Iswanna 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 Oct 23, 2025
Comment on lines 11 to 17
if (numerator < denominator && numerator !== 0) {
return true;
} else if (numerator >= denominator) {
return false;
} else if (numerator === 0) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The function won't work properly if numerator and denominator are allowed to be negatives.
For example -3 < 2 but -3/2 is not a proper fraction.

function getCardValue(card) {
if (rank === "A") {
card = card.substring(0 , card.length -1); // Remove the suit emoji
console.log(card);
Copy link
Contributor

Choose a reason for hiding this comment

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

For best practices, we should ensure code submitted in a PR free of any debugging code.

// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
if (rank === "A") {
card = card.substring(0 , card.length -1); // Remove the suit emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use a separate variable rank to represents the rank of a card?

We could reuse a variable but it is better not to use the same variable to store different kinds of value.

  • "A♠" => represent the value of a card
  • "A" ==> represent the value of a rank

Comment on lines 35 to 37
test("should identify reflex angle (>180° and <360°)", () => {
expect(getAngleType(250)).toEqual("Reflex angle");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

To make a test more robust, we could specify multiple expect(...) statements within each test() to cover multiple values that belong to the same case. For example,

test("should identify reflex angle (>180° and <360°)", () => {
  expect(getAngleType(300)).toEqual("Reflex angle");
  expect(getAngleType(359.999)).toEqual("Reflex angle");
  expect(getAngleType(180.001)).toEqual("Reflex angle");
});

Comment on lines 15 to 17
test("should return false for negative fractions", () => {
expect(isProperFraction(-4, 9)).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 quite match the test being performed.

Comment on lines 11 to 14
test("should return the numeric value for number cards from 2 to 10", () => {
const numberCard = getCardValue("7♥");
expect(numberCard).toEqual(7);
})
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 multiple values, especially the boundary cases "2♥" and "10♥".

@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 Oct 27, 2025
@Iswanna
Copy link
Author

Iswanna commented Oct 28, 2025

Hi @cjyuan.

Thank you so much for all the feedback. I will work on all of them and update all the necessary files.

@Iswanna
Copy link
Author

Iswanna commented Oct 29, 2025

Hi @cjyuan.

Thanks for your feedback! I’ve updated the code and tests to address all your suggestions.

@Iswanna Iswanna 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 Oct 29, 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 great.

You might have misunderstood the definition of proper fraction.

Comment on lines 13 to 25
let actualOutput;
// Denominator must be positive
if (denominator <= 0) {
actualOutput = false;
}
// Numerator must be positive and smaller than denominator
else if (numerator > 0 && numerator < denominator) {
actualOutput = true;
}
// All other cases are not proper fractions
else {
actualOutput = 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 equals to -2/3, and -2/-3 is equal to 2/3. So a fraction could still be considered as a proper fraction even if its denominator is negative.

  • -2/3 is a proper fraction.

Suggestion: Lookup the definition of proper fraction. You may also need to update the tests accordingly.

Copy link
Author

Choose a reason for hiding this comment

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

  • In math, 2/-3 equals to -2/3, and -2/-3 is equal to 2/3. So a fraction could still be considered as a proper fraction even if its denominator is negative.
  • -2/3 is a proper fraction.

Suggestion: Lookup the definition of proper fraction. You may also need to update the tests accordingly.

Hi @cjyuan.

Thank you for the clarification! You’re absolutely right. The sign of the denominator doesn’t affect whether a fraction is proper, and I should be comparing the absolute values instead.

I’ll update the function to handle negative denominators and negative numerators correctly and update the tests accordingly.

Copy link
Author

Choose a reason for hiding this comment

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

  • In math, 2/-3 equals to -2/3, and -2/-3 is equal to 2/3. So a fraction could still be considered as a proper fraction even if its denominator is negative.
  • -2/3 is a proper fraction.

Suggestion: Lookup the definition of proper fraction. You may also need to update the tests accordingly.

Hi @cjyuan.

Thank you for the clarification! You’re absolutely right. The sign of the denominator doesn’t affect whether a fraction is proper, and I should be comparing the absolute values instead.

I’ll update the function to handle negative denominators and negative numerators correctly and update the tests accordingly.

Hi @cjyuan.

I have updated the function and tests to correctly handle proper fractions with negative numerators or denominators. I also added additional test cases to ensure the function produces the expected output.
Thank you.

@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 Oct 29, 2025
@Iswanna Iswanna 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 Oct 29, 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 made to the function isProperFraction() looks good.

The test script could use some improvement. I will mark this PR as complete first.

Comment on lines 15 to 17
test("should return false for negative fractions", () => {
expect(isProperFraction(-4, 9)).toEqual(false);
expect(isProperFraction(-4, 9)).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 quite match the test being carried out.

  • Could also consider testing multiple values in each test.

Copy link
Author

@Iswanna Iswanna Oct 29, 2025

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 quite match the test being carried out.
  • Could also consider testing multiple values in each test.

Hi @cjyuan.

Thank you for the feedback. I have updated the test description to match the test. I have also tested more values for each test case.

@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. labels Oct 29, 2025
@Iswanna
Copy link
Author

Iswanna commented Oct 29, 2025

Changes made to the function isProperFraction() looks good.

The test script could use some improvement. I will mark this PR as complete first.

Hi @cjyuan.

Thank you so much for the detailed feedback throughout the review of my code. I really appreciate it, and it has been a valuable learning experience for me. Thank you also for marking my PR 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. Module-Structuring-And-Testing-Data The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants