Stuck - Javascript - Counting Cards

Hi again guys! It looks like these messages may become a daily thing lol. I’m stuck once again on a tutorial in JavaScript basics. It’s the Counting Cards one. Here is my 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:
    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');

Here is the error that follows:

SyntaxError: unknown: Unexpected token, expected “(” (28:5)

26 | }
27 |

28 | if count > 0 {
| ^
29 | return (count + " Bet");
30 | }else{
31 | return (count + " Hold")

I’ve tried Googling and just “chewing” on the problem a bit but I can’t seem to find my mistake. Any tips on fixing this error would be appreciated!

Also, any resources on learning to write pseudocode would also be appreciated! I think it’ll help me understand writing projects better :slight_smile:

Hi again guys! It looks like these messages may become a daily thing lol.

That’s why the forum is here.

if count > 0 {

JS requires the if condition to be wrapped in parentheses. When in doubt, refer to the docs.

1 Like

Thanks again Kevin! :slight_smile:

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