Just a thought here, why is it not correct this code set up? Curious (and yes I need to learn more hehe)

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

let count = 0;

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

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.71 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

This not a meaningful condition for an if statement. What does 2,3,4,5,6 mean? Javascript doesn’t understand what you want to do here.

Making use of comparison operators for your function parameters would fix this issue.

|| - is a logical “or” operator that compares its operands to see if either is true, and returns true if at least one operand is true.

I’m not entirely sure why separating the values with commas doesn’t work because I am still learning myself. Although, I think it is just a matter of syntax.

1 Like

It isn’t just that commas do not have syntactic meaning in this context. There is no condition that is being checked. If we look without the commas:

if (2) {

what is 2? where is 2? which 2? Javascript doesn’t know what you want to do with this 2.

1 Like

Ah, I see. My fault. So, if it was

if (card = 2)

it would be fine? And then just use the logical or operator to check for multiple numbers like (card = 2 || card = 3)?

Careful. = assigns a value to a variable. === is for comparisons

Thanks for the comment

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