|
8 | 8 | // write one test at a time, and make it pass, build your solution up methodically |
9 | 9 | // just make one change at a time -- don't rush -- programmers are deep and careful thinkers |
10 | 10 | function getCardValue(card) { |
11 | | - let rank = card.length === 1 ? card : card.slice(0, -1); |
| 11 | + let rank = card.slice(0, -1); |
12 | 12 | if (rank === "A") { |
13 | 13 | return 11; |
14 | 14 | } |
@@ -57,15 +57,15 @@ assertEquals(fiveofHearts, 5); |
57 | 57 | // Given a card with a rank of "10," "J," "Q," or "K", |
58 | 58 | // When the function is called with such a card, |
59 | 59 | // Then it should return the value 10, as these cards are worth 10 points each in blackjack. |
60 | | -const faceCards = getCardValue("J"); |
| 60 | +const faceCards = getCardValue("J♣"); |
61 | 61 | assertEquals(faceCards, 10); |
62 | 62 |
|
63 | 63 | // Handle Ace (A): |
64 | 64 | // Given a card with a rank of "A", |
65 | 65 | // When the function is called with an Ace, |
66 | 66 | // Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack. |
67 | 67 | const ace = getCardValue("A"); |
68 | | -assertEquals(ace, 11); |
| 68 | +assertEquals(ace, "Invalid card rank"); |
69 | 69 |
|
70 | 70 | // Handle Invalid Cards: |
71 | 71 | // Given a card with an invalid rank (neither a number nor a recognized face card), |
|
0 commit comments