File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change 88// write one test at a time, and make it pass, build your solution up methodically
99
1010function isProperFraction ( numerator , denominator ) {
11- if ( Math . sign ( numerator ) === - 1 || Math . sign ( denominator ) === - 1 ) {
12- if ( Math . abs ( numerator ) < Math . abs ( denominator ) ) {
13- return true ;
14- }
15- } else if ( numerator === 0 ) {
16- return false ;
17- }
18-
19- if ( numerator < denominator ) {
11+ if ( Math . abs ( numerator ) < Math . abs ( denominator ) ) {
2012 return true ;
2113 } else if ( numerator > denominator ) {
2214 return false ;
2315 } else if ( numerator === denominator ) {
2416 return false ;
17+ } else if ( numerator === 0 ) {
18+ return false ;
2519 }
2620}
2721
Original file line number Diff line number Diff line change 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
1010function getCardValue ( card ) {
11- const rank = card [ 0 ] ;
11+ let rank = "" ;
1212
13- if ( card === "A♠" ) {
14- return 11 ;
15- } else if ( Number ( rank ) > 1 && Number ( rank ) < 10 ) {
13+ for ( let i = 0 ; i < card . length - 1 ; i ++ ) {
14+ rank += card [ i ] ;
15+ }
16+
17+ if ( Number . isInteger ( Number ( rank ) ) && Number ( rank ) > 1 && Number ( rank ) < 10 ) {
1618 return Number ( rank ) ;
1719 } else if ( rank === "10" || rank === "J" || rank === "Q" || rank === "K" ) {
1820 return 10 ;
@@ -68,5 +70,5 @@ assertEquals(ace, 11);
6870// Given a card with an invalid rank (neither a number nor a recognized face card),
6971// When the function is called with such a card,
7072// Then it should throw an error indicating "Invalid card rank."
71- const invalidCard = getCardValue ( "15 ♠" ) ;
73+ const invalidCard = getCardValue ( "100 ♠" ) ;
7274assertEquals ( invalidCard , "Invalid card rank." ) ;
You can’t perform that action at this time.
0 commit comments