Somebody can assist me to pass Counting Card

Tell us what’s happening:
I all accord to video’s code to type,but still can’t pass

  **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":
case "A":
count--;break;
}
if(count>0){return count+"Bet"}else{return count+"Hold"}

return "Change Me";
// Only change code above this line
}
cc(2), cc(3), cc(4), cc(5), cc(6)
console.log(cc())
cc(7), cc(8), cc(9)
console.log(cc())
cc(10);cc('J');cc('Q');cc('k');cc('A')
console.log(cc())
cc(3); cc(7); cc('Q'); cc(8); cc('A');
console.log(cc())
cc(2); cc('J'); cc(9); cc(2); cc(7)
console.log(cc())
cc(2); cc(2); cc(10); 
console.log(cc())
cc(3); cc(2); cc('A'); cc(10); cc('K');
console.log(cc())



  **Your browser information:**

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

Challenge: Counting Cards

Link to the challenge:

The formatting of your return strings must be exactly as the instructions ask. For example, if you should bet, then the return string should be something like “5 Bet”. Notice the space between the number 5 and the word “Bet”. Do you have a space between these in your return statement?

Dear bb: Many thank your help,but I don’t know how to type so I think I give up!
bye bye!

hwapipi

Hey @hwapipi, your post doesn’t make sense to me? I think you know how to type. Or are you just being funny?

The challenge Word Blanks required you to add spaces in the string, how did you do that?

1.I am sorry,but my English is not good so I can’t understan your meaning,may be the before steps I don’t really understand so I cannot solve this step.
2.I am very interesting in coding,so feel coding is funny but the interest and funny thing that push me to learn. If you are…I am very sorry!
3.May be after few days go ,I return to solve this step probably can pass.

You can type your comments in your native language and we can use google translate to read them if that would help.

Your code is correct except for the return statement. You need to add a space between the number and the word. For example:

return count+"Bet"

If count equals 5, what string are you returning? Do you see a space between the number and the word “Bet”?

Dear bb:
I had retyped and had passed. Below is my typing:

var count = 0;

function cc(card) {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;
}if(count>0){return count+" Bet"}else{return count+" Hold"}
  // 只修改这一行下面的代码


  return "Change Me";
  // 只修改这一行上面的代码
}

cc(2);cc(3);cc(4);cc(5);cc(6)
console.log(cc())
cc(7);cc(8);cc(9)
console.log(cc())
cc(10);cc("J");cc("Q");cc("K");cc("A")
console.log(cc())
cc(3);cc(7);cc("Q");cc(8);cc("A")
console.log(cc())
cc(2);cc("J");cc(9);cc(2);cc(7)
console.log(cc())
cc(2);cc(2);cc(10)
console.log(cc())
cc(3);cc(2);cc("A");cc(10);cc("K")
console.log(cc())
'''
Though it had passed ,but the result is stranged.
cc(2);cc(3);cc(4);cc(5);cc(6)
console.log(cc())--------show 5 Bet
cc(7);cc(8);cc(9)
console.log(cc())--------show 5 Bet ,Why? It hould be 0 Hold .
cc(10);cc("J");cc("Q");cc("K");cc("A")
console.log(cc())--------show 0 Hold ,Why? It should be -5 Hold.
cc(3);cc(7);cc("Q");cc(8);cc("A")
console.log(cc())------show -1 Hold
cc(2);cc("J");cc(9);cc(2);cc(7)
console.log(cc())-------show 0 Hold, why? It hould be 1 Bet.
cc(2);cc(2);cc(10)
console.log(cc())-------show 1 Bet
cc(3);cc(2);cc("A");cc(10);cc("K")
console.log(cc())--------show 0 Hold , Why? It should be -1 Hold.

Dear i:
Thank you for helping I had passed!

if you don’t reset count, it keeps counting from where it stopped before (it was 5)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Dear i: Thank you to tell me ,no wonder the codes can’t show next time I will use```. Thanks!

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