Build a Card Counting Assistant - Build a Card Counting Assistant

Tell us what’s happening:

I have no idea what the hell I am doing, but I don’t know why this is wrong. Ignore the console.log(). I am using it to see what I am returning..

Your code so far

let count = 0;
function cc (card) {
  if (card === 1 || card === 2 || card === 3 || card === 4 || card === 5 || card === 6 ) {
    count += 1;
    betHold();
    return(count);
  } else if (card === 7 || card === 8 || card === 9){
    count = count;
     betHold();
    return count;
  } else if (card === 10 || card === "J" || card === "Q" ||card === "K" || card === "A") {
    count -= 1;
    betHold();
    return count;
  }

}

function betHold() {
  if (count > 0) {
    console.log(count + " Bet")
    return (count + " Bet" );
  }
  if (count <= 0) {
    console.log(count + " Bet");
    return (count + " Hold");
  }
}

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/141.0.0.0 Safari/537.36

Challenge Information:

Build a Card Counting Assistant - Build a Card Counting Assistant

Have you check what cc function returns? You can wrap the last call to cc with console.log like: console.log(cc(6));

This isn’t what you’re supposed to return

1 Like