Skip to content

Commit ed29b44

Browse files
committed
Refactor getCardValue and update tests to always include suit; remove unnecessary length check
1 parent deb0fe6 commit ed29b44

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
1010
function getCardValue(card) {
11-
let rank = card.length === 1 ? card : card.slice(0, -1);
11+
let rank = card.slice(0, -1);
1212
if (rank === "A") {
1313
return 11;
1414
}
@@ -57,15 +57,15 @@ assertEquals(fiveofHearts, 5);
5757
// Given a card with a rank of "10," "J," "Q," or "K",
5858
// When the function is called with such a card,
5959
// 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");
6161
assertEquals(faceCards, 10);
6262

6363
// Handle Ace (A):
6464
// Given a card with a rank of "A",
6565
// When the function is called with an Ace,
6666
// Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack.
6767
const ace = getCardValue("A");
68-
assertEquals(ace, 11);
68+
assertEquals(ace, "Invalid card rank");
6969

7070
// Handle Invalid Cards:
7171
// Given a card with an invalid rank (neither a number nor a recognized face card),

0 commit comments

Comments
 (0)