Tell us what’s happening:
please help i do not know what to do or is it because i don’t know how to play card
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;
}
return count + (count + 0 ? "Bet" : "Hold");
// 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');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36.
You’re actually a lot closer than you might think. And no, it’s not because you can’t play cards, neither can I
INSTRUCTIONS: Do NOT reset count to 0 when value is 7, 8, or 9.
What are you doing here?
count += 0;
INSTRUCTIONS: The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative.
So if the count is greater than zero, then you’ll get the word ‘Bet’. What is your condition on this line?
return count + (count + 0 ? "Bet" : "Hold");
Plus where is the space? Even it this line did work (which it doesn’t), it would output 5Bet, or 0Hold.
Your issue is in this line, one, you are missing a space between the number and the word
And you are not checking the value of count (count + 0 is not a comparison)
You are able to add a space on your own, I am sure, so let’s see the ternary operator
A ternary operator goes like this condition ? If true use this : else this
Right now as condition you have count + 0 which can’t become a Boolean (true or false), so you need to change that + in the middle to an operator that will make it a comparison, for example if you wanted to check if count was equal to 0 you would write count === 0 (note that this is not the comparison you need)
INSTRUCTIONS: The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative.
You are checking if count is 0 but instead you need to check if it is positive or not, I told you that that wasn’t the condition you needed
Bet if the count is positive, or Hold if the count is zero or negative.
Also if it would work you would return something like "2Bet" because you are missing a space between the number and the word. Your strings are "Bet"and "Hold", you have not added a space
If count was 2 you would get 2 + "Bet" which result as "2Bet", you need to add a space in therr