Tell us what’s happening:
I don’t really understand what I am doing here. Perhaps because I am not very good with math. But I can’t seem to get a single green check mark here. What am I doing wrong?
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 += 1;
break;
case 7:
case 8:
case 9:
count += 0;
break;
case 10;
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
break;
if count =< 0{
return count + "Bet";
} else {
return count = "Hold";
}
}
return count("Bet", "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; rv:60.0) Gecko/20100101 Firefox/60.0.
(when corrected) needs to be outside of the switch. You want that every time.
This:
return count("Bet", "Hold");
I don’t even know what that does.
Learn to use the browser console, usually something like ctrl-shft-j. There is a ton of useful information in there, not the least of which are the error messages for most of these problems.
I think I got the syntax errors resolved but now the logic seems off.
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 7:
case 8:
case 9:
count += 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count-;
break; }
if (count <= 0){
return count + " Hold";
} else {
return count + " Bet";
}
}
return count;
// 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; rv:60.0) Gecko/20100101 Firefox/60.0.
There are a couple of problems here. First of all, remember to indent properly. If you had, you might have noticed the extra close brace. Taking a few seconds to indent and format properly will more than pay off in the long run. Just make it a habit. Never code any other way.
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 7:
case 8:
case 9:
count += 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count-;
break;
}
if (count <= 0){
return count + " Hold";
} else {
return count + " Bet";
}
} // <-- extra close brace?
return count;
// 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');
Once you take care of that extra curly brace, you have a typo on this line:
count-;
Do you see it?
When I fix those two mistakes, your solution passes.
OMG man thank you. And thanks to all who replied to this, I took a little from each of you. I seriously drained some hours on this one. Learned some good lessons. Realizing adding an argument creates a function is not the least of them. Thanks all.