Skip to content

Conversation

@Fares-Bakhet
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

-Implementing cases and tests for each task.
-Test all the files using 'Jest'.

Questions

No questions.

@Fares-Bakhet Fares-Bakhet 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 12, 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.

Code is good. I just have a few suggestions.

if (angle < 90 && angle > 0) {
return "Acute angle";
}
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 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.

@cjyuan, Thanks for that. I have removed the unnecessary part.

Comment on lines 16 to 27
test("should return 10 for Jack of Diamonds", () => {
const jackofDiamonds = getCardValue("J♦");
expect(jackofDiamonds).toEqual(10);
});
test("should return 10 for Queen of Clubs", () => {
const queenofClubs = getCardValue("Q♣");
expect(queenofClubs).toEqual(10);
});
test("should return 10 for King of Hearts", () => {
const kingofHearts = getCardValue("K♥");
expect(kingofHearts).toEqual(10);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We could generalise these tests into one test to "should return 10 for face cards (J, Q, K)" and check all three ranks J, Q, K).

In addition, the function is not expected to check t the suit character. Indicating the suit character in the test description may send the developer the wrong message.

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan, I have generalised the test. Could you explain what you mean by check t?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a typo. Should be just "check the ..."

Comment on lines 11 to 14
test("should return 5 for Five of Hearts", () => {
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.

When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.

For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as

test("should return the value of number cards (2-10)", () => {
    expect(getCardValue("2♣︎")).toEqual(2);
    expect(getCardValue("5♠")).toEqual(5);
    expect(getCardValue("10♥")).toEqual(10);
    // Note: We could also use a loop to check all values from 2 to 10.
});

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan, Do I need to redo my tests again in a better way? Or is it just for future knowledge?😅😅

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 practice it now?

@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 23, 2025
@Fares-Bakhet Fares-Bakhet 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 23, 2025
return "Acute angle";
}
if (angle > 90 && angle < 180) {
if (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.

Can you find all places where you can remove redundant checks and update the code accordingly?

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan, okay.

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan,
If I want to rearrange this again, I will end up in this way:

  • 0 & < 90 >> covers 1-89

  • ==90 >> covers 90
  • 90 & <180 >>covers 91-179

  • ==180>>covers 180
  • 180 & <360 >> covers 181-359

  • invalid if sth else

Right??

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't tell. 180 & < 360 is not exactly JS code.

Copy link
Author

Choose a reason for hiding this comment

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

@cjyuan,
I was shortcutting
if( angle > 180 && angle <360)

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't know wat you try to expressed:
image

I suspect part of the code is misinterpreted as Markdown code. Here is the GitHub Markdown guide:
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

Comment on lines 16 to 22
test("should return 10 for all face cards (J, Q, K)", () => {
const faceCards = ["J♦", "Q♣", "K♥"];
faceCards.forEach((card) => {
const value = getCardValue(card);
expect(value).toEqual(10);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great.

@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 23, 2025
@Fares-Bakhet Fares-Bakhet 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 23, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Oct 23, 2025

The updated Jest tests looks good.

@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 23, 2025
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