Basic JavaScript - Counting Cards

Hello, I want to ask a question about this task. How can I return the count and the action with one space between them? It restricts me from including quotes (single or double) in the output, so I’m really confused

Your code so far

let count = 0;

function cc(card) {
  // Only change code below this line
  let action = "Hold";
  switch (card){
    case 2:
    case 3:
    case 4:
    case 5: 
    case 6:
      count += 1;
    case 7:
    case 8:
    case 9:
      count += 0;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
    count += -1;
  if (count > 0){
    action = "Bet"
    action = "Hold"
  return (count, action);
  // 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

There are a couple of solutions to get your output. You could concatenate the return using + , (count + " " + action).
If the Challenge wont accept this you could simply add a space in your action assignments:
" Bet"
" Hold"

1 Like

Also, consider that you can make your code a little tidier by not including cases 7-9. If you don’t need to do anything in those cases, you don’t need to include them.
It’s also tidier to increment/decrement using variable++ or variable--.
Note that these are just pointers rather than anything which breaks your code however!

1 Like

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