Hi guys, in this exercise, I am missing one card sequence, I tried and change all the possible values and still that It does not return the string value:
let count = 0;
function cc(card) {
// Only change code below this line
switch (card) {
case 9:
return "0 Hold";
break;
case 'A':
return "-5 Hold";
break;
case 6:
return "5 Bet";
break;
case 10:
return "1 Bet";
break;
case 7:
return "1 Bet";
break;
case 'K':
return "-1 Hold";
break;
case 'Q':
return "-1 Hold";
break;
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Console shows:
// running tests
Cards Sequence 3, 7, Q, 8, A should return the string -1 Hold
// tests completed
I tried to change the last âQâ for all the numbers that it should return the string â-1 Holdâ and It does not work. Any ideas?
This saying that every single time you see a 9 you must want the result 0 Hold
. Thatâs not consistent with the instructions.
(Note: easier for me to quote the instructions if you provide a link to the challenge)
You will write a card counting function. It will receive a card
parameter, which can be a number or a string, and increment or decrement the global count
variable according to the cardâs value (see table). 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. The current count and the playerâs decision (Bet
or Hold
) should be separated by a single space.
Lets break that into smaller chunks of text
-
You will write a card counting function.
-
It will receive a card
parameter, which can be a number or a string
-
increment or decrement the global count
variable according to the cardâs value (see table)
-
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 mixing together 3) and 4), but they really need to be done separately in your function.
1 Like
That means my whole function is wrong? Or Should I just change the values?
Because all the remaining strings from the exercise said are good.
Are you doing this in your function? It doesnât look it to me. You need to do part 3 first before you do part 4.
1 Like