Counting Cards - Why my solution is not working

Tell us what’s happening:

Why does solution not go through? I see that I have a bit of unnecessary code in there but theoretically it should just do fine. Atleast in the DevTools I get the desired outcome.

Your code so far

var count = 0;
var countNew = 0;
var strCount;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count =+ 1;
      break;
    case 7:
    case 8:
    case 9:
      count =+ 0;
      break;
    case 10:
    case 'J':
    case 'K':
    case 'Q':
    case 'A':
      count =- 1;
      break;
  }  
  
  countNew = count + countNew;  
  
  
   if (countNew <= 0) {
     strCount = "Hold";
   } else {
     strCount = "Bet";
   }
  
  return  countNew + " " + strCount;
  // 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:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/counting-cards

The culprit is the global countNew variable. The tests are using any previous value that it might have. You don’t have to use a countNew variable and just check the value in count. Or if you really want to keep the countNew variable, declare it inside the cc function.

Also, =+ and =- should be += and -= respectively.