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:
answer = count;
count++;
break;
case 7:
case 8:
case 9:
answer=count;
break;
case 10:
case J:
case Q:
case K:
case A:
answer = count;
count -1;
break;
}
if (answer > 0){
return count + "Bet";
}else
return count + "Hold";
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');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.
What’s the use you have of answer? You write count = answer but then you change count so you can’t evaluate answer anymore as it is not equal to count anymore
count -1 is not how you lower the value of a variable by one
You are missing a space in your output between count and the word you need to return
Hint
Do NOT reset count to 0 when value is 7, 8, or 9.
Do NOT return an array.
Do NOT include quotes (single or double) in the output.
see it,don’t single or double,and count to 0 when value 7.8.9.
so how to solve?
var count = 0;
function cc(card) {
// Only change code below this line
switch(card) {
case 2: case 3: case 4: case 5: case 6:
return "5 Bet";
break;
case 7: case 8: case 9:
return "0 Hold";
break;
case 10: case J: case Q: case K: case A:
return "-5 Hold";
break;
case 3: case 7: case Q: case 8: case A:
return "-1 Hold";
break;
case 2: case J: case 9: case 2: case 7:
return "1 Bet";
break;
case 2: case 2: case 10:
return "1 Bet";
break;
case 3: case 2: case A: case 10: case K:
return "-1 Hold";
break;
}
if (count > 0) {
return count + "Bet";
} else {
return count + "Hold";
}
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');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.
You have changed anything - you were more near it before
You are not updating the value of count… you are just trying to get the correct result for the tests - well, it will not work: your function accepts one card, count needs to be updated depending on the card value and then depending on count you return Bet or Hold
Your function is just returning 5 Bet, 0 Hold or -5 Hold, no other values can be returned from your function, and it is not updating count
I’m still confused,if write switch(card) { case 2: case 3: case 4: case 5: case 6: count++; break; case 7: case 8: case 9: count; break; case 10: case ‘J’: case ‘Q’: case ‘K’: case ‘A’: count–; break; }
if (count > 0) { return count + “Bet”; } else { return count + “Hold”; }
I don’t think it will work??