I know I can try with Switch but idk why my if statement is failing
**Your code so far**
let 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 + "Bet";
} else {
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 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0
Challenge: Counting Cards
Link to the challenge:
Sky020
#2
Welcome there,
To help debug, I suggest adding the following line somewhere in your code:
console.log(cc("A"));
Then, look at the output, and compare that to one of the expected outputs shown in the tests.
Click for hint:
Remember, programming is completely specific - case and space sensitive
Hope this helps
1 Like
Thanks for the tip. I think I kind of figured the problem now. My code only goes thru the first number in card sequence. I need to look into that.
No. The function is only called on one card at a time. That is the way itβs designed.
You should look at the string that your function returns.
1 Like
Ahh, " " matters 
Well I thought the card was a sequence of numbers or strings then the function gives you a count plus either hold or bet.
1 Like
system
closed
#6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.