Counting Cards exercise

Can I ask that there be, perhaps, a better way for the test to indicate where the issue is? I mean, I understand that in real life situations you have to figure these things out for yourself. But in a case like this the test never says: your output doesn’t look exactly the way we want it to. I was focusing on making sure that the function works properly, would never have thought to notice whether there was a space or not.
The only reason I know how to use the console at all is because I learned it from a different bootcamp that I did when I found this one too confusing to start with. I came back because I wanted to get more practice and learn better but I’m finding its idiosyncrasies really frustrating.

The iniosyncrasies are kind of just how programming is. Small details matter to computers. There is no ‘roughly right’ as far as the computer knows, only ‘correct’ and ‘something is wrong’.


Lets look at the first test here

Cards Sequence 2, 3, 4, 5, 6 should return the string 5 Bet

Ok, there is not too much that can go wrong here. Either

  1. The number is wrong
  2. Hold vs Bet is wrong
  3. The output formatting is wrong

In this case I would look at the sample function usage:

cc(2); cc(3); cc(7); cc('K'); cc('A');

and then modify it to cover this test case

cc(2); cc(3); cc(4); cc(5); cc(6);

and then log the output

cc(2); cc(3); cc(4); cc(5); console.log(cc(6));

Doing this would let me see 5Bet.

I then know

  1. The number is correct
  2. The Hold vs Bet is correcct
  3. But the output formatting looks different

If I were writing this function for the first time (as is true in my console) there would be no predetermined format I would be aiming to match. Same is true if this were a real life project for work. Details of output formatting would be my decision or predetermined and I would know specifically what was expected. I guess now I know that one of the things I’m looking for in the exercises is the output format but that wasn’t really made clear (until you just told me) and it’s the lack of clarity I’m finding in many of the lessons and exercises that is really causing me problems.

Not at all! In professional work you are designing functions that need to meet certain specifications in order to correctly integrate with the rest of the software project your team is working on.

This is true, and the challenge did tell you what to do:

The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player’s decision ( Bet or Hold ) should be separated by a single space.

The information is there, but you have to read carefully. This holds true with professional work. The small details matter.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.