Hi !
I believe you did not understand the concept of the question.
You will receive a sequence of cards. Based on those cards, you will count: add 1 if cards between 2 & 6; subtract 1 if cards between 10 & ‘A’. (the other cards don’t change the counter). Once you have gone through the sequence of cards, then you will produce the result: if count > 0, your current count plus ‘Bet’, if count <= 0, your current count plus ‘Hold’.
Does this help?
EDay69 is right. You’ve not quite understood what the cc() function needs to do:
First update the global count variable based on the current card passed in as an argument. Right now, your function doesn’t touch count at all.
I would recommend focusing on this task first. Make sure that calling cc() updates count as required. Your if-else structure is attempting to do this, but it has some problems. First of all, the code in that chain of if-else statement should NOT return anything. It should merely update the value of count.
In addition, there are some problems with the boolean expressions that are controlling the structure. For example card >= 2 || card <= 6 will return true for any number at all because every number is either greater than 2 or less than 6.
Once you are sure that the first part of your function is updating the value of ‘count’ correctly, then add additional code to check the new value of count and return a bet/hold recommendation.
I hope this is helpful. Reply if you need clarification.
Please read my comment above. There are many reasons why it is not working.
If you want to work through them issue by issue, start with this:
if(card>=2 || card<=6) {
return "5 Bet"
}
Right now this code is causing your function to return ‘5 Bet’ whenever the card is greater than or equal to 2 OR less than or equal to 6. That is wrong.
What it should be doing is adding 1 to the count variable whenever the card is greater than or equal to 2 AND less than or equal to 6.
Perhaps see if you can just fix that small issue first.