File tree Expand file tree Collapse file tree
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,22 +40,22 @@ function getCardValue(card) {
4040 ] ; // array with ranks
4141 const tenPointsFaceCards = [ "K" , "Q" , "J" ] ; //cards with value of 10 points
4242
43- const rank1 = card . slice ( 0 , - 1 ) ; //takes the firs part of card
44- const suit1 = card . slice ( - 1 ) ; //takes "suit" secnd part of card
45- const isCardValid = suit . includes ( suit1 ) && rank . includes ( rank1 ) ; //conditions where card is considered valid
43+ const firstBit = card . slice ( 0 , - 1 ) ; //takes the firs part of card
44+ const secondBit = card . slice ( - 1 ) ; //takes "suit" secnd part of card
45+ const isCardValid = suit . includes ( secondBit ) && rank . includes ( firstBit ) ; //conditions where card is considered valid
4646
4747 //conditional statement to check validity of the card
4848 if ( ! isCardValid ) {
4949 throw new Error ( "Invalid card format" ) ;
5050 }
5151
5252 //conditional statements to check what value to return depending on the card value
53- if ( rank1 === "A" ) {
53+ if ( firstBit === "A" ) {
5454 return 11 ;
55- } else if ( tenPointsFaceCards . includes ( rank1 ) ) {
55+ } else if ( tenPointsFaceCards . includes ( firstBit ) ) {
5656 return 10 ;
5757 } else {
58- return Number ( rank1 ) ;
58+ return Number ( firstBit ) ;
5959 }
6060}
6161
@@ -180,4 +180,4 @@ try {
180180 console . error ( "Error was not thrown for invalid card 😢" ) ;
181181} catch ( e ) {
182182 console . log ( "Error thrown for invalid card 🎉" ) ;
183- }
183+ }
You can’t perform that action at this time.
0 commit comments