Counting Cards - pass test error

Tell us what’s happening:

Your code so far


var count = 0;

function cc(card) {
  // Only change code below this line
  if(card >= 2 && card <= 6){
    count+=1;
    //return count;
  }else if(card >=7 && card <= 9){
    count=count;
   // return count;
  }else if(card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
    count-=1;
   // return count;
  }
  
  if(count > 0){ 
    return count + " Bet";
  }else{
    return count + " hold";
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
/*
 cc(7);
 cc(8);
 cc(9);
console.log(cc());
*/
/*
 cc(10);
 cc("J");
 cc("Q");
 cc("K");
 cc("A");
console.log(cc());
*/
cc(3);
 cc(7);
 cc("Q");
 cc(8);
 cc("A");
console.log(cc());

/*
 cc(3);
 cc(2);
 cc("A");
 cc(10);
 cc("K");
console.log(cc());
*/

Your browser information:

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

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

remember you need to return Hold, coding is case sensitive

1 Like

Although your solution passes with your existing code, you might want to ask yourself if the above else if statement is necessary.