Tell us what’s happening:
Describe your issue in detail here.
I tried solving it with if statements and as well as switch statement, but neither of those seem to work. And I’m just not being able to find the mistake. Can someone please spot my mistake from the code?
**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 += 1;
break;
case 7:
case 8:
case 9:
count += 0;
break
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
break;
}
if (count <= 0) {
return count, "Hold";
}
else {
return count, "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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
The return string needs to have a space between the count and Hold/Bet
Using a comma to combine the count and Hold/Bet isn’t doing what you intend. Try adding the following at the bottom and then look in the console pane below the editor to see what it gives you:
console.log(cc(1));
Do you know of another way to add a variable and string together so they make one string?
Oh my god! It worked now. Thanks!
I added a space infront of “Hold” and “Bet”. Then I used the “+” operator instead of comma to concatenate. And it worked!
I think there’s only these two ways to add a string and a variable which returns another string. One is adding a comma between them and the other is adding a plus operator between the string and the variable. However, there might be other ways but I don’t know cuz I’m still a beginner.