File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,11 @@ function getCardValue(card) {
1515 if ( rank === "J" || rank === "Q" || rank === "K" ) {
1616 return 10 ;
1717 }
18+
19+ rank = Number ( Math . floor ( rank ) ) ;
20+
1821 if ( ( rank => 2 ) && ( rank <= 10 ) ) {
19- return Number ( rank ) ;
22+ return rank ;
2023 }
2124 return "Invalid card rank." ;
2225}
@@ -69,4 +72,16 @@ assertEquals(ace, 11);
6972// When the function is called with such a card,
7073// Then it should throw an error indicating "Invalid card rank."
7174const invalidCards = getCardValue ( "hello" ) ;
72- assertEquals ( invalidCards , "Invalid card rank." ) ;
75+ assertEquals ( invalidCards , "Invalid card rank." ) ;
76+
77+ // strings that represent valid numeric literals
78+ const numericLiterals1 = getCardValue ( "hello" ) ;
79+ assertEquals ( numericLiterals1 , "Invalid card rank." ) ;
80+
81+ const numericLiterals2 = getCardValue ( "hello" ) ;
82+ assertEquals ( numericLiterals2 , "Invalid card rank." ) ;
83+
84+
85+ // console.log(getCardValue("0x02♠")); // 2
86+ // console.log(getCardValue("2.1♠")); // 2
87+ // console.log(getCardValue("0002♠")); // 2
You can’t perform that action at this time.
0 commit comments