Count value not decrementing when 10 is passed

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:

You want to decriment when the card is a ten.

yes, and all the cases where 10 value is passed are failing

You are not decrementing based on card, read that line carefully for a typo.

thanks a lot Jeremy!
My bad…
didn’t notice the typo

1 Like

Happens to all of us :slight_smile: