Try using this, i just work through it using this more simplify switch statement.
var count = 0;
function cc(card) {
// Only change code below this line
var answer="";
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count = count;
break;
case 10:
case “J”:
case “Q”:
case “K”:
case “A”:
count–;
break;
}
if( count <= 0){
return count+" Hold";
}
else if ( count > 0){
return count+ " Bet";
}
return “Change Me”;
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);
That doesn’t work because case evaluates equality. Essentially, if you wrote switch (variable) and case(testCase), it would perform variable === testCase, or, in this case, card === card >= 2 && card <= 6.
It would then run the code in the case statement if card === card >= 2 && card <= 6 evaluated to True.
For what you’re trying to do, you’d need to write if (card >= 2 && card <= 6) {statement;}
When I enter the soultion into Chrome console what should I see as result? “Bet” or “Hold”? I add at the very end: “function cc(2)” (without quotes of course) but it returns only “Uncaught SyntaxError: Unexpected number” . What do I do wrong? What will be the correct way to test this code working? Thanks in advance! Yarve