Counting Cards - Can't seem to get past the challenge

Tell us what’s happening:
I keep getting error me

Your code so far


var count = 0;

function cc(card) {
  // Only change code below this line
  
      var cValue = 0;

  switch (card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      cValue = 1;
      break;
    case 7:
    case 8:
    case 9:
      cValue = 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      cValue = -1;
  }
  
  
  

  count = count + cValue;

  var decision = "";

  if (count > 0){
				decision = "Bet";
			  } else if (count <= 0){
				decision = "Hold"
			  } 
  var currentCount = count + "" + decision;

  return currentCount;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Your browser information:

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

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

Ola seja bem vindo ao fórum! Uma dica, para fazer a contagem você precisa fazer um incremento.

Sorry, could you use English?
Thanks alot…

Sorry! Hello, welcome to the forum! One tip, to do the count you need to make an increment. For example, count ++, count --.

Thanks alot. Have adjusted my code (see below) but still having error message:

var count = 0;

function cc(card) {
  // Only change code below this line

  switch (card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    card += 1;
    break;
   
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    card -= 1;
  }


  if (count > 0){
				return count + " Bet";
			  }
				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(5); cc(4); 

Your code is almost ready missing just a few tweaks. Note that the variable responsible for counting is count, card is a parameter. You made the increment the wrong way.

But close to the solution.

Thanks so much for the point out! :+1: I did the corrections and boom!!! it went through… You’ve made me a better programmer. You are the bomb!!! :fireworks:

See code below:

var count = 0;

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 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    count -= 1;
  }


  if (count > 0){
				return count + " Bet";
			  }
				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(5); cc(4);

Congratulations! Happy coding!