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 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count==="-1";
break;
}
if (count==="+1"){
return "Bet";
}else{
return "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 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15.
switch (card)
{
case 2:
case 3:
case 4:
case 5:
case 6:
count===+1;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count===-1;
break;
}
if (count===+1){
return count + "Bet";
}else{
return count + "Hold";
}
ok that doesn’t really match the description of the problem though. So let me explain what +1 or -1 means in the challenge.
What they want is for you to count up or down depending on the card you see.
If you want to count up for example, you add 1.
If you want to count down , you subtract 1.
I’m assuming you know enough javascript to be able to code that…
If not, I can find some of the old challenges for you to help you learn that.
Actually I went though previous challenges trying yo find out what am I missing. But I got stuck.
so to add value of the count by one I return count++ and to count-- to subtract?
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;
}
if (count > 0){
return count + "Bet";
}else{
return count + "Hold";
}
Exactly, so don’t include those numbers in your else if logic. With your last code posted, you would be subtracting one from count for number 7, 8, or 9.