Counting Cards 2

The entire code doesn’t work, what could be the problem?

  **Your code so far**

let 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++;
   break;  
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
let holdbet = 'Hold'
if (count > 0) {
holdbet = 'Bet'
}

return count + "" + holdbet; 


// Only change code above this line
}

cc(2); cc('K'); cc(10); cc('K'); cc('A');
console.log(cc(4))
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39

Challenge: Counting Cards

Link to the challenge:

What does this line do?

@JeremyLT is for Return holdbet variable.

Why is there an empty string in there?

1 Like

HI @Baleni123 !

Pay close attention to what your console.log is printing right now.
Screen Shot 2022-05-14 at 4.13.33 PM

It looks like you were trying to add a space here

But you will have to modify that empty string to fix the spacing issue.
Once you fix the spacing issue, then the test will pass.

Hope that helps!

1 Like

And remember 7, 8 and 9 should not add or subtract from count.

@Lego_My_Eggo I removed the adding on the count, my code works, thank you

@jwilkins.oboe Code works after adding space, thank you

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