You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A),
47
+
// Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will
48
+
// be a number 2-10, or one letter of J, Q, K, A),
32
49
// When the function getCardValue is called with this card string as input,
33
50
// Then it should return the numerical card value
34
-
constaceofSpades=getCardValue("A♠");
35
-
assertEquals(aceofSpades,11);
51
+
// const aceofSpades = getCardValue("A♠");
52
+
// assertEquals(aceofSpades, 11);
36
53
37
54
// Handle Number Cards (2-10):
38
55
// Given a card with a rank between "2" and "9",
39
56
// When the function is called with such a card,
40
57
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
41
58
constfiveofHearts=getCardValue("5♥");
59
+
assertEquals(fiveofHearts,5)
60
+
61
+
constsixofHearts=getCardValue("6♥");
62
+
assertEquals(sixofHearts,6);
42
63
// ====> write your test here, and then add a line to pass the test in the function above
43
64
44
65
// Handle Face Cards (J, Q, K):
45
66
// Given a card with a rank of "10," "J," "Q," or "K",
46
67
// When the function is called with such a card,
47
68
// Then it should return the value 10, as these cards are worth 10 points each in blackjack.
69
+
constfaceCards=getCardValue("J♥");
70
+
assertEquals(faceCards,10)
71
+
72
+
assertEquals(getCardValue("Q♥"),10);
73
+
48
74
49
75
// Handle Ace (A):
50
76
// Given a card with a rank of "A",
51
77
// When the function is called with an Ace,
52
78
// Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack.
79
+
constaceofSpades=getCardValue("A♠");
80
+
assertEquals(aceofSpades,11);
53
81
54
82
// Handle Invalid Cards:
55
83
// Given a card with an invalid rank (neither a number nor a recognized face card),
56
84
// When the function is called with such a card,
57
85
// Then it should throw an error indicating "Invalid card rank."
0 commit comments