Not sure why Counting Cards isn't working

Tell us what’s happening:
I can’t figure out why my code isn’t being accepted. Please help me figure out what I’m doing wrong.

Your code so far


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':
      count--;
      break; 
  }
  if (count > 0) {
    return count + "Bet";
  } else {
    return count + "Hold";
  }
  
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 11316.165.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.122 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

You are really really close

Wrap one of the function calls in a console.log(), so that you will see in the console what the function returns

Thanks.

I don’t understand where exactly to put it.

I tried to put it at the end:

console.log(cc(2));

And this is the result I got:

/ running tests
Cards Sequence 10, J, Q, K, A should return -5 Hold
Cards Sequence 3, 7, Q, 8, A should return -1 Hold
Cards Sequence 3, 2, A, 10, K should return -1 Hold
// tests completed

You should look at the console before running the tests, for example that one should give you something in the console

I got results in the consol, but when I “run tests” that’s what comes up.

And you should see the difference between what you see in the console and what the tests say

Good thing I’m not a gambler. I forgot to add case 'A': :roll_eyes:

I didn’t notice that one

I was talking about your output

Again, thanks.

Once I added the ace, the tests worked.

Curious, because you were missing a space