File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed
Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,7 @@ function getCardValue(card) {
1818 return 10 ; // Face cards
1919 }
2020
21- if ( rank === "A" ) {
22- return 11 ; // Ace
23- }
21+ if ( rank === "A" ) return 11 ; // Ace
2422
2523 // Anything else is invalid
2624 throw new Error ( "Invalid card rank" ) ;
Original file line number Diff line number Diff line change 11function getCardValue ( card ) {
2- // replace with your code from key-implement
3- return 11 ;
2+ if ( rank === "A" ) return 11 ;
43}
5- module . exports = getCardValue ;
4+ module . exports = getCardValue ;
Original file line number Diff line number Diff line change 11const getCardValue = require ( "./3-get-card-value" ) ;
22
33test ( "should return 11 for Ace of Spades" , ( ) => {
4- const aceofSpades = getCardValue ( "A♠" ) ;
5- expect ( aceofSpades ) . toEqual ( 11 ) ;
6- } ) ;
4+ const aceofSpades = getCardValue ( "A♠" ) ;
5+ expect ( aceofSpades ) . toEqual ( 11 ) ;
6+ } ) ;
7+
8+ const aceofSpades = getCardValue ( "A♠" ) ;
9+ assertEquals ( aceofSpades , 11 ) ;
10+
11+ const fiveofHearts = getCardValue ( "5♥" ) ;
12+ assertEquals ( fiveofHearts , 5 ) ;
13+
14+ const tenofDiamonds = getCardValue ( "10♦" ) ;
15+ assertEquals ( tenofDiamonds , 10 ) ;
16+
17+ const jackofClubs = getCardValue ( "J♣" ) ;
18+ assertEquals ( jackofClubs , 10 ) ;
19+
20+ const queenofHearts = getCardValue ( "Q♥" ) ;
21+ assertEquals ( queenofHearts , 10 ) ;
22+
23+ const kingofSpades = getCardValue ( "K♠" ) ;
24+ assertEquals ( kingofSpades , 10 ) ;
25+
26+ try {
27+ getCardValue ( "Z♠" ) ;
28+ } catch ( error ) {
29+ console . log ( "Caught error:" , error . message ) ;
30+ }
731
832// Case 2: Handle Number Cards (2-10):
933// Case 3: Handle Face Cards (J, Q, K):
You can’t perform that action at this time.
0 commit comments