Build a Card Counting Assistant - Build a Card Counting Assistant

Tell us what’s happening:

I don’t understand how to make the if / else statement execute and to get it to display the current count with either “Bet” or “Hold”
Please help!!

Your code so far

let count = 0;

function cc(card){
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      return count + 1;
      break;
    case 7:
    case 8:
    case 9:
      return count;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      return count - 1;
  }
   if(count <= 0){
    return`${count} Hold`;
  }else{
    return `${count} Bet`;
  }
 
}

console.log(cc(2));
console.log(cc(3));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Build a Card Counting Assistant - Build a Card Counting Assistant

Please re-read User Story #10 to see what the function should return. Then look at Tests #4-10. You will need to get a count for the previous cards.

Will your code ever get to if(count <= 0){?

Yes I think it does? However it never displays “Bet” or “Hold”. I cannot get that part of the function to work,

However when i try console.log(cc(0)) it DOES display 0 hold. But not for any of the other numbers / variables. It just says the count

Any ideas on what’s wrong?

I’ve noticed that the count doesn’t stack. It only displays 1, -1 or 0

Are you sure it does? What happens when we write a return statement?

What happens when 0 hits the switch statement?

Are you updating the global count variable inside your switch?

Aaa omg tysm!! It was the return statements :smiling_face_with_tear: :grin: