Skip to content

Commit 36e8c14

Browse files
committed
converted the cardRnk string to a number and added a check for the ace card, which can have a value of either 1 or 11 depending on the context of the hand. This allows the function to correctly calculate the value of the hand in blackjack, where the ace can be counted as either 1 or 11 to maximize the player's chances of winning.
1 parent fa537b2 commit 36e8c14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function getCardValue(card) {
3030
if (cardRank === "A") return 11;
3131
if (["J", "Q", "K"].includes(cardRank)) return 10;
3232
if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(cardRank))
33-
return cardRank; // the parseint() or Number() can be used to convert the string to a number
33+
return Number(cardRank); // the parseint() or Number() can be used to convert the string to a number
3434
throw new Error("invalid card rank");
3535
}
3636

0 commit comments

Comments
 (0)