Counting Cards I am stuck :( the first 3 task is checked green but after that ...?

Counting Cards I am stuck :( the first 3 task is checked green but after that ...?
0

#1

Tell us what’s happening:

Your code so far


var count = 0;

function cc(card) {
  // Only change code below this line
if (card >1 && card <7){
  return "5 Bet";
} else if (card >6 && card<10){
  return "0 Hold";
} else if (card == 10 || card === "J", "Q", "K", "A"){
  return "-5 Hold";
} else if (card =="3", "7", "8" & card === "Q", "A"){
  return "-1 Hold";
}
  

 

  return "Change Me";
  // 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 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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


#2

These if else statements don’t make sense. You have to actually compare each values such as “7” or “J” to card everytime and you can’t separate them by commas.

I recommend using switch statement which is already taught prior to this exercise.

Also You should compare numbers instead of string of numbers.


#3

On top of what @shimphillip said, you are not even using the count variable. I would re read the instructions and implement that.


#4

Thanks for correcting me ! I will change it to switch statement.
Its tricky sometimes seeing the green checks on the screen for the first 3 task and than it is all wrong!
Thanks again!!


#5

I know the last else if statement doesn`t make sense but the one before actually worked :smiley:

Thanks for the recommendation!