11// This problem involves playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck
22
3- // Implement a function getCardValue,
4- // when given a string representing a playing card, it should return the numerical value of the card.
3+ // Implement a function getCardValue, when given a string representing a playing card,
4+ // should return the numerical value of the card.
55
66// A valid card string will contain a rank followed by the suit.
77// The rank can be one of the following strings:
88// "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"
99// The suit can be one of the following emojis:
1010// "♠", "♥", "♦", "♣"
11- // For examples, "A♠", "2♥", "10♥", "J♣", "Q♦", "K♦".
11+ // For example: "A♠", "2♥", "10♥", "J♣", "Q♦", "K♦".
1212
1313// When the card is an ace ("A"), the function should return 11.
1414// When the card is a face card ("J", "Q", "K"), the function should return 10.
1515// When the card is a number card ("2" to "10"), the function should return its numeric value.
1616
17- // When the card string is invalid (not following the above format), the function should
17+ // When the card string is invalid (not following the above format), the function should
1818// throw an error.
1919
2020// Acceptance criteria:
2121// After you have implemented the function, write tests to cover all the cases, and
2222// execute the code to ensure all tests pass.
2323
2424function getCardValue ( card ) {
25- // TODO: Complete the implementation
25+ // TODO: Implement this function
2626}
2727
2828// The line below allows us to load the getCardValue function into tests in other files.
@@ -38,17 +38,15 @@ function assertEquals(actualOutput, targetOutput) {
3838}
3939
4040// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
41- // Examples:
41+ // Examples:
4242assertEquals ( getCardValue ( "9♠" ) , 9 ) ;
4343
44-
4544// Handling invalid cards
4645try {
4746 getCardValue ( "invalid" ) ;
4847
4948 // This line will not be reached if an error is thrown as expected
5049 console . error ( "Error was not thrown for invalid card" ) ;
51- } catch ( e ) {
52- }
50+ } catch ( e ) { }
5351
54- // What other invalid card cases can you think of?
52+ // What other invalid card cases can you think of?
0 commit comments