Counting cards switch else if

I didn’t get this: can anyone tell me what’s wrong and what should be right? Thanks

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 regex =/[JQKA]/;

if (card > 1 && card < 7) {
count ++
} else if (card === 10 || regex.test (car)) {

count --;
}

if (count > 0) return count + "Bet";
return count  + "Hold";




// Only change code above this line
}

cc(2); cc ('K'); cc(10); cc('K'); cc('A');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Counting Cards

Link to the challenge:

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 (’).

What is going on with this?

Hello there! Reading the many solutions in counting cards (which I’ve tried most of them), I suppose that we don’t have the same test. Here’s mine:

  1. Card sequence 2, 3, 4, 5, 6 should return 5 Bet
  2. Card sequence 7, 8, 9 should return the string 0 Hold
  3. Card sequence 10, J, Q, K, A should return the string
    -5Hold
  4. Card sequence 3, 7, Q, 8, A should return -1 Hold
  5. Card sequence 2, J, 9, 2, 7 should return 1 Bet
  6. Card sequence 2, 2, 10 should return 1 Bet
  7. Card sequence 3, 2, A, 10, K should return -1 Hold

The first three answer I 've given (below) are recognize as right, the other ones (which I’ve also tried with if else statement suggested) don’t work.
Can anyone help me to close this exercise? Thanks

let count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
return  "5 Bet";


case 7:
case 8:
case 9:
return "0 Hold";


case 10:
case "J":
case "Q":
case "K":
case "A":
return "-5 Hold";

case 3:
case 7:
case "Q":
case 8:
case "A":
return "-1 Hold";

case 2:
case "J":
case 9:
case 2:
case 7:
return "1 Bet";

case 2:
case 2:
case 10:
return "1 Bet";

case 3:
case 2:
case "A":
case 10:
case "K":
return "-1 Bet";

}









// 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 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Counting Cards

Link to the challenge:

You don’t need to make that many switch case statements. Don’t pay attention to the tests instead look at what are the conditions.
Screenshot 2021-11-15 184604

Make switch case or if - else statements by referring to this chart

Make a ‘count’ variable that increments when it meets the respective conditions and decrements the same. You don’t have to make switch statements for when the count variable doesn’t increment or decrement.

Hope that helps

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 (’).

I’ve tried with the explanations’ written in the first description of counting cards exercise: also I tried to follow the example in ‘get help’s: I’ve tried all the exercises suggested by other code camp members, but is still incomplete.
Can anyone help me to move on, not replying the same answer/solutions’ given?

Thanks

let count = 0;

function cc(card) {
// Only change code below this line


return "Change Me";
// 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 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Counting Cards

Link to the challenge:

Hi @lineup475 !

Right now we don’t know what you are struggling with in this challenge because you only posted the starter code.

Please post your attempt to this challenge and we can work from there.

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 (’).

You need to clarify which part of completing the challenge proves hard to you.

The function “cc” is meant to modify the value of the variable “count” based on the card passed to the function and also return the updated value of count plus suggested for the player to “Bet” or “Hold” based on if count value is greater than 0 or not.
We have 3 separate brackets of cards. In one bracket are the cards which would increment count by 1, in another bracket are the cards which would decrement count by one and the 3rd bracket are cards which does not affect the count value. Depending on what card is passed to your function(depending which bracket it is), you should modify the count value. You can use if/else conditions, or switch(there are also other options) for that.
Once you have count updated, based on the card passed, your function should return the count value, and the suggestion “Bet” or “Hold”, depending on if count is greater than 0. For example if count===-5 we should return "-5 Hold", or if count===2, the return value should be "2 Bet".

Tell us what’s happening:
Describe your issue in detail here.

 What's wrong with this?

Thanks

let  count = 0;

function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
 return "5 Bet"; 
break;
case 7:
case 8:
case 9:
 return "0 Hold";
 break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
 return "-5 Hold"; 
break;
}
let count = holdbet;
if (cc(3),cc(7),cc('Q'),cc(8),cc('A')){
return "-1 Hold";
}
if (cc(2),cc('J'),cc(9),cc(2),cc(7)) {
return "1 Bet";
}
if (cc(2),cc(2),cc(10)) {
return "1 Bet";
}
if (cc(3),cc(2),cc('A'),cc(10)) {
return "-1 Hold";
}


return count +1,-1;
// 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 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Counting Cards

Link to the challenge:

The first thing that I notice is that you have a lot of return statements in here.
Remember that a return statement will stop the execution of the function.
If you place any return statements in the switch, then the if statements will never be executed.


There a few things to address. Let's start by focusing on the switch statement. The directions say to increment the count by 1 if the card is 2,3,4,5, or 6.

Right now your code says return 5 Bet.

You need to change that so the count is incremented by one.

The directions also say, if the card is 7,8, or 9 then you are not going to change the count variable at all.
You can just delete all of this part.

Then the directions say if count is 10, J,Q,K, or A decrement the count by 1.
Right now your code is saying to return -5 Hold which is incorrect.

You need to change that to say count is decremented by 1

For your if statements here, it looks like there is some confusion on how these test cases work. So I would go ahead and delete all of this .

You want to have one if statement and one else clause.

Here is the logic.

if count is positive
  then we will return the current count and Bet
else
  then we will return the current count and Hold

Hope that helps!