Challenge Counting Cards has an issue.
User Agent is: Mozilla/5.0 (Windows NT 5.1; rv:44.0) Gecko/20100101 Firefox/44.0
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
var count = 0;
function cc(card) {
// Only change code below this line
switch (card) {
case 'J':
case 'Q':
case 'K':
case 'A':
case 10:
count--;
}
if (count < 7) {
count++;
}
if (count <= 0) {
return count + " Hold";
}else if (count > 0) {
return count + " Bet";
}
return "Change Me";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(9); cc('Q'); cc(8); cc('A');
It looks to me like this code works. Several users in the chat said this should work. But, I keep on getting it wrong. I believe this is a bug,
Nope, not a bug. Hint, here's your problem:
if (count < 7) {
count++;
}
Just one thing here needs to change and your code will pass. If you compare this if
statement with your switch
statement you'll see what's wrong.
Ah... Thank you @alistermada Didn't realize that I put in the wrong variable. Thank you!
Thanks @alistermada !
_Content Hidden - by mod [raisedadead]_
_Content Hidden - by mod [raisedadead]_
_Content Hidden - by mod [raisedadead]_
@ouzatl please do not post solutions or code on this thread, you can visit chat rooms and forum for assistance on code.
Most helpful comment
_Content Hidden - by mod [raisedadead]_