Skip to content

Commit 9f3ed4f

Browse files
assigned rang with the value of card[0]
1 parent c5b9e52 commit 9f3ed4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
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-
if (rank === "A") {
11+
let rank=card[0]
12+
if (rank=== "A") {
1213
return 11;
1314
}
15+
1416
}
1517

1618
// The line below allows us to load the getCardValue function into tests in other files.
@@ -31,14 +33,15 @@ function assertEquals(actualOutput, targetOutput) {
3133
// 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),
3234
// When the function getCardValue is called with this card string as input,
3335
// Then it should return the numerical card value
34-
const aceofSpades = getCardValue("A♠");
35-
assertEquals(aceofSpades, 11);
36+
const aceOfSpades = getCardValue("A♠");
37+
assertEquals(aceOfSpades, 11);
3638

3739
// Handle Number Cards (2-10):
3840
// Given a card with a rank between "2" and "9",
3941
// When the function is called with such a card,
4042
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
41-
const fiveofHearts = getCardValue("5♥");
43+
const fiveOfHearts = getCardValue("5♥");
44+
assertEquals(fiveOfHearts,5)
4245
// ====> write your test here, and then add a line to pass the test in the function above
4346

4447
// Handle Face Cards (J, Q, K):

0 commit comments

Comments
 (0)