Javascript counting card

Count Change	Cards
+1	                              2, 3, 4, 5, 6.
0	                                7, 8, 9.
-1	                       10, 'J', 'Q', 'K', 'A'

if the card is positive //2,3,4,5, or 6
it should return count + " Bet".

and if the card is // 10, ‘J’, ‘Q’, ‘K’, or ‘A’,
it should return count + " Hold"

  **Your code so far**

let count = 0;

function cc(card) {
// Only change code below this line
const Low = [2,3,4,5,6];
const High =[10,'J', 'Q','K','A']
}else if(High.includes(card)){

if(Low <= 0){
return count + " Bet";
return count + " Hold";
// 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

It seems like you your code doesn’t pass the test cases. Instead of telling you the answer, I suggest you to debug your code and see where the flaw is, you can use console.log() on the places where you have returned some value and check whether the logged output = the output expected in the test cases. If you still were unable to solve the problem, I encourage you to go to the hints page to get some hints.

If you find the hints/solutions difficult to understand, We are here to solve your doubts.

Happy Coding :grinning:.

It seems you’ve misunderstood the instructions.

Whether you return “Hold” or “Bet” is based on the value of count, not card.

card is used to update the count, then count is used to determine which string to return.

1- On your Final Conditional you have your Array LOW to be checked against. You should be checking your Count instead because that is what dictates whether its a hold or a bet.

2- Still on that conditional, you are checking for 0 or negative numbers first. I’d probably increase that check range by check first for the positives, and then the 0 and lower. That was the change I made and it checked okay after doing it.

Hope it helped. Good luck

thank you for that ,i appriciate.

oh thank you very much.

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