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.

return 11;
} if (card === "J" || card === "Q" || card === "K" || card === "10") {
return 10;
} else if (card >= 2 && card <=9) {
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. Do you want to recognize these string values as valid ranks?

To find out what these strings are, try asking AI

What kinds of string values would make card >= 2 && card <=9 evaluate to true?

// 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.

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