Counting Cards - a few requirements not passing

I know i can write my code in a concise way but i cannot understand why a few requirements of my test are failing. For example:
Cards Sequence 2, 3, 4, 5, 6 should return 5 Bet

The issue i’m having is that 2 of the requirement are running well so i’m unsure of what the issue is.
Here are the 2 requirements that have passed

  1. Cards Sequence 2, J, 9, 2, 7 should return 1 Bet
  2. Cards Sequence 2, 2, 10 should return 1 Bet

Your code so far


var count = 0;

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

// Add/remove calls to test your function.
// Note: Only the last will display
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_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

You have a few issues:

  1. Make sure you understand the difference between the assignment operator = and comparison operators such as == and === related to your if statement conditions.

  2. When you make comparisons with variables and values in your if statements, you have to compare each value to the variable. You can not just put the variable on the left of an operator and the separate the values by commas. Make sure to review the section on comparison operators again, because you will not see what you are trying to do here anywhere in the curriculum.

  3. Finally, don’t try to hard code the values of count for the return value (count + " Bet" or “Hold”). Instead, think about how you could just compare count to a single value in your if statement and then an else statement would deal with the other scenario.

Add console.log(count) after your first block of if…else statements so you can see what the value of the variable is

There are some issues.
First, when you write count = +1 the code variable is being set to 1, it is not adding one to the count variable. Same thing for all the others.

Then, you use something like card= 2,3,4,5,6 in the if statement. This is not a comparison, this is an assignment operator (you are saying card is now equal to 2) and a bunch of numbers.
Instead a comparison is done like card == 2 (and you need a comparison for each card, with the OR logical operator ||), or you can use a range using more than and less than >, <
You have the same issue with the other if statement.

You can see the flow of your code with this: http://pythontutor.com/javascript.html

Thank You so much for taking the time to review my code and help me. I have finally solved the issue!

Thank You so much - i used a range and also learnt how to increment a variable. Appreciate your insight here!! New to coding but learning along the way - thanks again