My code wont return properly in the JavaScript Counting Cards exercise

When I run the code without case 7 - 9 as the video instructs, it errors out stating that cards 7-9 should return 0 and Hold. I am confused because the hints state “Do NOT reset count to 0 when value is 7, 8, or 9.*” So when I try and accommodate the error in my code, it’s not budging.

My code is below:

let count = 0;

function cc(card) {

  // Only change code below this line

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case "J":
case "Q":
case "K":
case "A":

var holdbet = 'Hold';
if (count > 1 || count < 7){
  holdbet = 'Bet';

return (count + " " + holdbet)

// Only change code above this line

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

That’s an “or” - and every number is bigger than one OR smaller than 7. I think you want to use an “and”.

Also please provide a link to the challenge, so we can read the entire task and see if anything else might be amiss :wink:

1 Like

What they are talking about with 7, 8, and 9 is that they should not add or subtract from the count, and they should basically “do nothing”. And its easy to forget that count = 0 actually resets the count to zero rather then “do nothing” when you are first learning, so its a good heads up for people learning. And if you look at your code 7-9 are actually “doing something”, which you do not want them to do. Also one of your positive or negative counters is missing something.


Here is a link to my problem

I hope this worked.

After re-reading this, are you getting hung up on the “Hold”/“Bet” part? because that portion is just looking for “Bet” if count is one or more, or “Hold” if its zero or less, not 7-9

1 Like

Two issues

  1. Hold/Bet is based upon if count is positive or negative, not between 1 and 7

  2. In the case of 7, 8, and 9, you should not be decrementing the count.


Okay, I think I understand.

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