Tell us what’s happening: When running this code, it is failing in the test cases when value 10 is passed to the card. Count value is not decrementing for value 10
For example: cc(10) would return 0 Bet while it should return -1 Hold
Your code so far
var count = 0;
function cc(card) {
var regex = /[JQKA]/;
if(card > 1 && card < 7){
count++;
} else if(count==10 || String(card).match(regex)){
count--;
}
if(count > 0)
return count + " Bet";
return count + " Hold"
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36
.
Challenge: Counting Cards
Link to the challenge: