Counting Cards - hard time understanding the exercise

Tell us what’s happening:
Describe your issue in detail here.
I dunno if it’s me, but I think the exercises are poorly laid out. I can’t fully get what I am supposed to do.

  **Your code so far**

let count = 0;

function cc(card) {
// Only change code below this line


return "Change Me";
// Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:96.0) Gecko/20100101 Firefox/96.0

Challenge: Counting Cards

Link to the challenge:

What part do you find unclear? How can we help you?

I think quite a lot of people struggle with this.
The questions start to give you less and less help to start getting into the mindset you need when solving problems all by yourself. I find rereading the question several times and writing psuedo code really helps me. As an example for this problem I might write this:

// get card and make sure it is what Im expecting
// if (card 2, 3, 4, 5, 6)      bet++
// if( card 10, 'J', 'Q', 'K', 'A')         bet--
// else bet doesnt change... Do I even need this?
// return bet

Then I’ll start filling out the sections and deciding how to solve the problem with actual code. For example the first line of my psuedo code doesn’t even apply to this problem. I just add it to everything as I’ve wasted so many hours debugging because I haven’t properly though about the input.

Hi Damian:

I mulled over why I got so confused––I totally overthought the whole thing, which lead me down some holes. I’m definitely gonna start things out with pseudo-code so as to aid me in learning to solve problems. Cheers.

Hi Ariel: Instead of trying to understand what was given to me, I assumed (note to self: never assume anything) I was basically only going write a whole bunch of switch cases and that was gonna be it. As that did not work, I thought it had to do with the order of the cases (like how cards are counted). The funny thing is that I’m not a total newbie and have used a count before, but totally overlooked it. I’m going to follow Damian’s advice and write pseudo-code to aid me in the solving of problems.

Good job working through it. I also have a tendency to overcomplicate when I try to start writing code before I’ve figured out my whole plan. Have fun and happy coding!

Thanks. I’ve just completed one of the Objects exercise by first writing it in pseudo-code, and it helped lots.

1 Like

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