Counting cards. Help with my code please

Counting cards. Help with my code please
0

#1
var answer;
var count = 0;

function cc(card) {
  // Only change code below this line
  if (card <= 6) {
    count --;
  } else if (card <= 9) {
    count += 0;
  } else {
    count ++;
  }
  
  if (count > 0) {
    amswer = count + " Bet";
  } else {
  
  answer = count + " Hold";
  }
  
  return answer;
  // 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');

Why does this not work? Not sure what I am missing. A little help please.


#2

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

As to your problem,

  1. Double check that your counting logic meets the challenge requirements. Hint: it does not.
  2. Make sure all of your variables are spelled correctly.

#3

A much easier way to write this would be with a switch statement.


#4

Thanks for the help. Don’t know how I missed that. Fixed the spelling and counting and it works now.