Skip to content

Commit 138843b

Browse files
committed
10 card case
1 parent 716f047 commit 138843b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ function getCardValue(card) {
1616
}
1717

1818
const numValue = parseInt(rank, 10);
19-
if (numValue >= 2 && numValue <= 10) {
19+
if (numValue >= 2 && numValue < 10) {
2020
return numValue;
2121
}
22+
if (rank === "10" || rank === "J" || rank === "Q" || rank === "K") {
23+
return 10;
24+
}
2225
}
2326

2427
// The line below allows us to load the getCardValue function into tests in other files.
@@ -54,6 +57,8 @@ assertEquals(fiveofHearts, 5);
5457
// Given a card with a rank of "10," "J," "Q," or "K",
5558
// When the function is called with such a card,
5659
// Then it should return the value 10, as these cards are worth 10 points each in blackjack.
60+
const kingofDiamonds = getCardValue("K♦");
61+
assertEquals(kingofDiamonds, 10);
5762

5863
// Handle Ace (A):
5964
// Given a card with a rank of "A",

0 commit comments

Comments
 (0)