File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ 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" ) {
22+
23+ if ( rank === "J" || rank === "Q" || rank === "K" ) {
2324 return 10 ;
2425 }
26+
27+ // If we get here, it's an invalid card - return undefined
28+ return undefined ;
2529}
2630
2731// The line below allows us to load the getCardValue function into tests in other files.
@@ -71,3 +75,6 @@ assertEquals(aceofClubs, 11);
7175// Given a card with an invalid rank (neither a number nor a recognized face card),
7276// When the function is called with such a card,
7377// Then it should throw an error indicating "Invalid card rank."
78+ const invalidCard = getCardValue ( "1♣" ) ;
79+ assertEquals ( invalidCard , undefined ) ;
80+
You can’t perform that action at this time.
0 commit comments