Skip to content

Conversation

@Amirmontazerii
Copy link

@Amirmontazerii Amirmontazerii commented Feb 21, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@Amirmontazerii Amirmontazerii added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2025
@cjyuan cjyuan added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Mar 1, 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.

Look great!

getCardValue(card) could be improved to deal with more invalid cases.

Feel free to mark this as completed when you have made the necessary change.

Comment on lines +11 to 16
if (angle === 90) return "Right angle";
if (angle < 90) return "Acute angle";
if (angle > 90 && angle < 180) return "Obtuse angle";
if (angle === 180) return "Straight angle";
if (angle > 180 && angle < 360) return "Reflex angle";
}
Copy link
Contributor

@cjyuan cjyuan Mar 1, 2025

Choose a reason for hiding this comment

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

The spec does not specify what to do when angle >= 360. How would you handle such a case if it were up to you?

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 your review! I've updated the function to handle additional cases.

const rank = card.slice(0, -1);
if (rank === "A") return 11;
if (["K", "Q", "J", "10"].includes(rank)) return 10;
if (!isNaN(rank) && rank >= 2 && rank <= 9) return Number(rank);
Copy link
Contributor

Choose a reason for hiding this comment

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

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

getCardValue("010♠");
getCardValue("02♠");
getCardValue("0x02♠");
getCardValue("2.1♠")

Copy link
Author

Choose a reason for hiding this comment

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

I updated the function so now It shows that the function throwing errors for invalid card inputs .

@@ -1,5 +1,5 @@
function countChar(stringOfCharacters, findCharacter) {
return 5
return stringOfCharacters.split(findCharacter).length - 1;
Copy link
Contributor

@cjyuan cjyuan Mar 1, 2025

Choose a reason for hiding this comment

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

Very interesting and elegant approach!
Since a character is of type "string" in JS, how would you modify your approach to deal with cases when findCharacter is "abc" or ""?

Copy link
Author

Choose a reason for hiding this comment

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

The current approach works for single characters but can also handle multi-character substrings, However, there are some edge cases, so improved the function to handle theme.

@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 Mar 1, 2025
@Amirmontazerii Amirmontazerii added the Complete Volunteer to add when work is complete and all review comments have been addressed. label Mar 8, 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. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants