-
-
Notifications
You must be signed in to change notification settings - Fork 197
ZA Cape Town | ITP-May-2025 | Dawud Vermeulen | Module-Structuring and Testing Data Sprint-3 #688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally looking pretty good, but please format your code to be easier to read, and make sure you tidy things up (e.g. remove obsolete comments).
return 11; | ||
const rank = card.slice(0, -1); // works to extract the rank and ignores the suit | ||
if (rank === "A") return 11 //works | ||
else if (["J", "Q", "K", "10"].includes(rank)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your other implementation you included 10
in the 2-9 case, but in this one you're including it in the J/Q/K case - both work, but can you talk through which you think is simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@illicitonion yes, its just makes more sense for it to be bundled with the face cards due to value. whats your thoughts? want me to make any changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'd probably bundle it with the numbers - my thinking here is:
Either way, you need to write an upper bound of the numbers you're looking for. So the difference between:
if (rank >= 2 && rank <= 10) {
compared with
if (rank >= 2 && rank <= 9) {
is basically no difference at all in terms of simplicity. Whereas the difference between :
if (["J", "Q", "K"].includes(rank)) {
and
if (["J", "Q", "K", "10"].includes(rank)) {
involves writing a whole extra thing, so feels slightly more complex.
// Case 5: Handle Invalid Cards: | ||
test("should throw an error for invalid card", () => { | ||
expect(() => getCardValue("Z♠")).toThrow("Invalid card rank."); //not sure how to write this test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a comment here saying you're not sure how, but it looks like you have - is it something you want to talk through, or if not, please remove the comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@illicitonion just me talking to myself. figured it out. let me remove the comment. thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see the comment - please remove :) But glad you worked it out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry about that. looks like its gone now.
update for the sake of the PR comments. fix to handle the over sights.
updating to remove unnecessary indentation
remove the unnecessary comments. clean code.
Learners, PR Template
Self checklist
Changelist
Completed all exercises in the following subfolders:
Questions
Please review my code 🪻🙏🏽