Can someone tell me why this code wont run?

Tell us what’s happening:

Your code so far


var count = 0;

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

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
    count++;
break; 

case 7:
case 8:
case 9:
   count +=0
break;

case 10:
case "J":
case "Q":
case "K":
case "A":
     count-1;
break;
}

if (count <0 || count ===0){
return count+" Bet";
} else {
return count+" Hold";
};

// 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

Challenge: Counting Cards

Link to the challenge:

This doesn’t reassign the value of count.

2 Likes

Hey!

I think you need to take a look at the instructions more thoroughly.
The instructions say:

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 following line in your code needs fixing.

if (count < 0 || count === 0){
return count+" Bet";
} else {
return count+" Hold";
};

Also, as mentioned, count-1, does not change the value of count. Either use count-- or count-=1

Hope this helps!