var count = 0;
function cc(card) {
// Only change code below this line
switch(card) {
case 2,3,4,5,6:return "5 Bet";
case 7,8,9:return "0 Hold";
case 10,'J','Q','K','A':return "-5 Hold";
case 3,7,'Q',8,'A':return "-1 Hold";
case 2,'J',9,2,7:return "1 Bet";
case 2,2,10:return "1 Bet";
case 3,2,'A',10,'K':return "-1 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.3; WOW64; rv:63.0) Gecko/20100101 Firefox/63.0.
@chunguz Just curious, why did you decide to write the case statements to match the tests? I think part of the point of this challenge involves incrementing and decrementing.
@camper can u pliz help me solve this at least tell me what am doing wrong. I don’t understand the point of this challenge and besides what does incrementing and decrementing mean??
@chunguz Incrementing means to add 1 to something and decrementing means to subtract 1 from something. Here’s the text from 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.
With the switch statement, you’ll update your var count depending, and then if the result is positive you’ll display “X Bet” else if the result is 0 or negative you’ll display “X Hold”.
@mangasource Hi:smiley:
all the cases are correct except for case 3,7,‘Q’,8,‘A’: return “-1 Hold”; I have tried everything in my power I can’t seem to pass this case to pass the entire test so can you pliz tell me what am doing wrong am so frustrated:weary:
var count = 0;
function cc(card) {
// Only change code below this line
switch(card) {
case 2,3,4,5,6:return "5 Bet";
case 7,8,9:return "0 Hold";
case 10,'J','Q','K','A':return "-5 Hold";
case 3,7,'Q',8,'A':return "-1 Hold";
case 2,'J',9,2,7:return "1 Bet";
case 2,2,10:return "1 Bet";
case 3,2,'A',10,'K':return "-1 Hold";
}
It looks like you’ve misunderstood that the function cc evaluates cards only one at a time. The function itself only needs to carry out the following actions:
increment, decrement, or do nothing to the value of count
return a string that contains the count followed by Bet or Hold depending on count’s value