Whats's wrong with my code?

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

  **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 = count + 1;
return count;

case 7:
case 8:
case 9: 
return count;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count = count -1;
return count;

}
}

cc(3); cc(7); cc('Q');cc(8);cc('A');

if (count<=0){
console.log(count," Hold");
}
else{
console.log(count," Bet");
}
  **Your browser information:**

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

Challenge: Counting Cards

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.


Your function is returning a number, not the required string

A few ideas:

  • Remove return because that exits the function with that return value
  • Use break to end the switch

This is not very important, but you can use the increment operator to update the value of count i.e count++, and count–, or count+=1 and count-=1.

Out of the switch, you need some condition. This a basic example of a switch using break:

function example(val){
switch(val){
 case 1:
   val++
   break 
 case 2:
   val+=2
   break
 }
 return val 
/*return val>1? 'may be 2':'it is one!' (example w cond.)*/
}