You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,11 @@
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
functiongetCardValue(card){
11
-
if(rank==="A"){
11
+
letrank=card[0]
12
+
if(rank==="A"){
12
13
return11;
13
14
}
15
+
14
16
}
15
17
16
18
// The line below allows us to load the getCardValue function into tests in other files.
@@ -31,14 +33,15 @@ function assertEquals(actualOutput, targetOutput) {
31
33
// 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),
32
34
// When the function getCardValue is called with this card string as input,
33
35
// Then it should return the numerical card value
34
-
constaceofSpades=getCardValue("A♠");
35
-
assertEquals(aceofSpades,11);
36
+
constaceOfSpades=getCardValue("A♠");
37
+
assertEquals(aceOfSpades,11);
36
38
37
39
// Handle Number Cards (2-10):
38
40
// Given a card with a rank between "2" and "9",
39
41
// When the function is called with such a card,
40
42
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
41
-
constfiveofHearts=getCardValue("5♥");
43
+
constfiveOfHearts=getCardValue("5♥");
44
+
assertEquals(fiveOfHearts,5)
42
45
// ====> write your test here, and then add a line to pass the test in the function above
0 commit comments