Card Counter Increment/Decrement [Solved]

Card Counter Increment/Decrement [Solved]
0

#1

Can someone tell my why I couldn’t use count++ or count-- here to increment or decrement the global variable of count?

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 = count + 1;
break;

case 7:
case 8:
case 9:
  count = count + 0;
  break;
 
case 10:
case "J":
case "Q":
case "K":
case "A":
  count = count - 1;
  break;

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

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(7); cc(‘Q’); cc(8); cc(‘A’);


#2

Did you try it and the tests failed? I see no reason why they wouldn’t.


#3

I found the problem. I was using them like:

count = count++;

Instead of using it strictly

count++;