Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getAngleType(angle) {
if (angle < 90 && angle > 0) {
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

return "Obtuse angle";
}
if (angle === 180) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ console.log(getCardValue("10♣"));
console.log(getCardValue("J♦"));
console.log(getCardValue("A♥"));
console.log(getCardValue("11♠"));
console.log(getCardValue("J"));
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ test("should return 5 for Five of Hearts", () => {
expect(fiveofHearts).toEqual(5);
});
// Case 3: Handle Face Cards (J, Q, K):
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);
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.

// Case 4: Handle Ace (A):
test("should return 11 for Ace of Spades", () => {
Expand Down