Card Counting in javascript

I’ve been trying to write my code for the counting cards program but for some reason I keep getting : " Cards Sequence 7, 8, 9 should return 0 Hold
Cards Sequence 3, 7, Q, 8, A should return -1 Hold
Cards Sequence 2, J, 9, 2, 7 should return 1 Bet
Cards Sequence 2, 2, 10 should return 1 Bet
Cards Sequence 3, 2, A, 10, K should return -1 Hold"

I added:
return “5 hold”;
to the case #'s 2 thru 6 and that gave me a check mark beside one of the objectives. But it also voided out the
break;
I added at the end.

I looked at the help videos as well as the solutions and as far as I can tell my code is no different from theirs. Can some one please tell me why my code wont work?

Could you be so kind to share your code?


this is my code. everything beneath this is the same as the help solutions answer.

Well, you shouldnt return anything in the switch statement, only increment or decrement the global count variable which you are already doing in your code.
So try to remove returns in your switch statement.

PS: it would be better for us if you copy and paste your code here. the picture of it makes it hard.

I removed the ‘return’ but now its saying I have everything wrong.
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 10:

case "J":

case "Q":

case "K":

case "A":

  count--;

  break;

}

if (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’);

The challenge is asking you to return:
return count + " Hold" or return count + " Bet"

But you are returning: return count + " hold" or return count + " bet"

Make the first letters of “bet” and “hold” capital, so it’s going to pass.

Thanks yigit! That was the issue

More than welcome. Happy coding!

Cheers