Basic JavaScript - Counting Cards

Tell us what’s happening:
Pls, I need an assistance. I have been stuck in this lesson for over three days. I still cant pass this stage till now… Can someone pls correct my mistakes for me? Thanks in anticipation

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 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
  count--; break;

  var holdbet = "hold"
if (count > 0) { holdbet = "bet"}
return count +" " + holdbet
  // Only change code above this line

cc(10); cc('J'); cc('Q'); 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:

1 Like

Computers can be very picky about case. Lowercase and uppercase letters are completely different. Are you sure you are returning the exact strings as asked for in the instructions?

1 Like

I have done my possible best

If you are still having problems then please paste your updated code in here so we can see what you did.

To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key. You may also be able to use Ctrl+e to automatically give you the triple back ticks while you are typing in the this editor and the cursor is on a line by itself. Alternatively, with the cursor on a line by itself, you can use the </> button above the editor to add the triple back ticks.

I’m done with it. Thanks

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