Tell us what’s happening:
Describe your issue in detail here.
Followed the code shown in the video step by step but was still not able to pass the challenge.
Also how can the “if” operator be used inside a variable??
**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++;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;}
var holdbet='Hold'
if(count > 0){holdbet= 'Bet';}
return count + "" + holdbet;
// 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/91.0.4472.164 Safari/537.36
Hey I have changed the code a little bit and also tried to add the console.log in the end if you would look at the image. ’
But I have was still not able to complete the challenge, could you please help me.
I have tried putting all the different values the challenge expects and the function works properly( as you could see in the image as well ), but still I have not been able to get past the challenge.
How should I separate the players count and the decision with single space? I have separated the code however but the result in the console is not separated.
Thanks man!!! It worked perfectly, added two inverted commas in between the count and hold/bet string in the return statement. And I was able to complete the challenge.
count is a variable holding a number. When you use + with a variable holding a number and a string or a variable holding a string, then JavaScript converts the number to a string during the concatenation.