Basic JavaScript - Counting Cards

Tell us what’s happening:
I created this solution and tested it myself. it works but doesnt pass the test. Am i doing something wrong? maybe im not allowed to use switches?
thx for reading

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

    case 10:case "J": case "Q":case "K":case "A": return count-=1;break;}
    if(count<=0){return count+" "+ "Hold"}
    else{ return count + " "+"Bet"}
  // Only change code above this line
}

cc(10); cc("J"); cc("Q"); cc("K"); cc("A");



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/105.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

It doesn’t work. This is not what the instructions want you to return.

Same here


Side note, please format your code so it is easier for others to actually read it.

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