Card count result always 0

Describe your issue in detail here.

Always my output is zero to the count card challenge


let count = 0;

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

cc(2); cc(3); cc(7); cc('K'); cc('A');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/13.2 Chrome/83.0.4103.106 Mobile Safari/537.36

Challenge: Counting Cards

Link to the challenge:

Someone please help me with these challenge.

In the instructions:

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

In your code:

else if (card == 7 || card == 8 || card ==9){
  count = 0;
}

Ok thanks i am gonna try that.

Sorry, I mean the instructions say not to reset the count to 0, but in your code you have reset the count to 0. So you need to not do that.

I remove that part but i can’t get a return value. Thale output still the same.

The instructions say:

Bet if the count is positive, or Hold if the count is zero or negative

Also the instructions say:

The current count and the player’s decision ( Bet or Hold ) should be separated by a single space.

Your solution does not currently follow these instructions.

Try logging the value you return before returning it to see what’s going on.

Thanks a lot men i change my code to switch and i did it still thanks a lot.

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