question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Counting Cards Example Output Misleading

See original GitHub issue

In the Basic JavaScript section of the Front End Development Certification, the directions for the Counting Cards challenge show the following Example Output:

 "-3 Hold"
 "5 Bet"

Since previous challenges deal with escaping characters such as the double quote, I thought the solution required double quotes around the result as depicted in the Example Output. After spending some time troubleshooting my code, I discovered that the expected answer is one without quotes. For example:

-3 Hold
 5 Bet

In order to avoid confusion, I think the Example Output should not include double quotes around the output. It misleads the coder into thinking that double quotes should be a part of the output when the accepted answer is not expecting them.

As an alternative, the system could accept results that include quotes in the output.

Sample Code

if (count>0) return “"” + count + " Bet"“; //This code fails because it includes escaped double quotes if (count<=0) return count + " Hold”; //This code passes because it doesn’t include quotes

Challenge Name: Counting Cards

https://www.freecodecamp.com/challenges/counting-cards#?solution= var count %3D 0%3B function cc(card) { %2F%2F Only change code below this line switch (card){ case 2%3A case 3%3A case 4%3A case 5%3A case 6%3A count%2B%2B%3B break%3B case 7%3A case 8%3A case 9%3A break%3B case 10%3A case 'J'%3A case 'Q'%3A case 'K'%3A case 'A'%3A count--%3B break%3B } %2F%2F if (count>0) return '"' %2B count %2B ' Bet"'%3B if (count>0) return "\"" %2B count %2B " Bet\""%3B if (count<%3D0) return count %2B " Hold"%3B %2F%2F Only change code above this line } %2F%2F Add%2Fremove calls to test your function. %2F%2F Note%3A Only the last will display %2F%2Fcc(2)%3B cc(3)%3B cc(7)%3B cc('K')%3B cc('A')%3B cc(2)%3B cc(3)%3B cc(4)%3B cc(5)%3B cc(6)%3B %2F%2Freturns "5 Bet" %2F%2Fcc(7)%3B cc(8)%3B cc(9)%3B %2F%2Freturns "0 Hold" %2F%2Fcc(10)%3B cc('J')%3B cc('Q')%3B cc('K')%3B cc('A')%3B %2F%2Freturns "-5 Hold"

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
BKinahancommented, Aug 15, 2016

I think the instructions are quite clear that Bet and Hold are themselves strings without needing the double quotes around them in the code format, so those can probably be removed. It would be useful to have some way of distinguishing different types in the instructions (eg without needing to use quotes to specify something is a string), but I’m not sure what form that would take.

There is some inconsistency about string format in instructions, output, and test messages between various challenges and it would be great to have some unified style there to prevent confusion as seen in other issues similar to this one.

0reactions
Internetworldcommented, Sep 10, 2016

to solve quotation in answer just modify return statement to be like this

return (‘"’+count + " “+'Hold”');

use single quotes to define it is as a string and combine it with double quotes as an output with the string result

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blackjack Card Counting - Learn the Wong Halves System
Here's an example for you: If the dealer deals a jack first, you'll subtract 1 from your starting count of 0. This brings...
Read more >
I used programming to figure out how card counting really works
So I wrote a minimal program that simulates gameplay with card counting. How did I do it, and what were the results? Let's...
Read more >
How Blackjack Card Counting Works - LiveAbout
Card counting will only give you a one to two percent edge over the house, and the advantage you gain by card counting...
Read more >
Card counting - Wikipedia
Card counting is a blackjack strategy used to determine whether the player or the dealer has an advantage on the next hand. Card...
Read more >
Counting Cards With A Neural Net. Can Machine Learning ...
Sometimes Machines Learn The Wrong Thing. As you can see below, when given card count data, the neural net is able to do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found