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
// The line below allows us to load the getCardValue function into tests in other files.
@@ -31,27 +40,44 @@ function assertEquals(actualOutput, targetOutput) {
31
40
// 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),
32
41
// When the function getCardValue is called with this card string as input,
33
42
// Then it should return the numerical card value
34
-
constaceofSpades=getCardValue("A♠");
35
-
assertEquals(aceofSpades,11);
43
+
constaceOfSpades=getCardValue("A♠");
44
+
assertEquals(aceOfSpades,11);
36
45
37
46
// Handle Number Cards (2-10):
38
47
// Given a card with a rank between "2" and "9",
39
48
// When the function is called with such a card,
40
49
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
41
-
constfiveofHearts=getCardValue("5♥");
50
+
constnineOfHearts=getCardValue("9♥");
42
51
// ====> write your test here, and then add a line to pass the test in the function above
52
+
assertEquals(nineOfHearts,9);
43
53
44
54
// Handle Face Cards (J, Q, K):
45
55
// Given a card with a rank of "10," "J," "Q," or "K",
46
56
// When the function is called with such a card,
47
57
// Then it should return the value 10, as these cards are worth 10 points each in blackjack.
58
+
constkingOfDiamonds=getCardValue("K♦");
59
+
assertEquals(kingOfDiamonds,10);
60
+
constqueenOfClubs=getCardValue("Q♣");
61
+
assertEquals(queenOfClubs,10);
62
+
constjackOfHearts=getCardValue("J♥");
63
+
assertEquals(jackOfHearts,10);
64
+
consttenOfSpades=getCardValue("10♠");
65
+
assertEquals(tenOfSpades,10);
48
66
49
67
// Handle Ace (A):
50
68
// Given a card with a rank of "A",
51
69
// When the function is called with an Ace,
52
70
// Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack.
71
+
constaceOfHearts=getCardValue("A♥");
72
+
assertEquals(aceOfHearts,11);
53
73
54
74
// Handle Invalid Cards:
55
75
// Given a card with an invalid rank (neither a number nor a recognized face card),
56
76
// When the function is called with such a card,
57
77
// Then it should throw an error indicating "Invalid card rank."
0 commit comments