Why I am getting error message

“// running tests Cards Sequence 2, J, 9, 2, 7 should return the string 1 Bet // tests completed”

var count = 0;

function cc(card) {
  // Only change code below this line
if (card == 2 || card == 3 || card == 4 || card == 5 || card == 6){
  count += 1;
} else if(card == 7 || card == 8 || card == 9){
  count = 0;
} else if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
  count -= 1;
}
if (count <= 0)
{
  return count + " Hold";
} else {
  return count + " Bet";
}

  
  // Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A');

Why?

As cards 7, 8,9 has count 0

Common misunderstanding that’s sometimes overlooked in the instructions :slight_smile: you should add zero to the count, not set the count to zero.

oops thank Jeremy!! I will remember this :slightly_smiling_face:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.