Basic JavaScript - Counting Cards

Tell us what’s happening:
code is working but i dont know why its not going to next step

Your code so far

let count = 0;

function cc(card) {
  // Only change code below this line
if (card==2 || card==3 || card==4 || card==5 || card==6){
  count++;
  return count +" Bet";
}
else if (card==10 || card=='J' || card=='Q' || card=='K' || card=='A'){
  count--;
  return count +" Hold";
}
else{
  count = count+0;
  return count +" Hold";
}

  
  // Only change code above this line
}
console.log(cc(2), cc('J'), cc(9), cc(7), cc(2));

Your browser information:

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

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

Its failing on these two tests:

Cards Sequence 2, J, 9, 2, 7 should return the string 1 Bet
Cards Sequence 2, 2, 10 should return the string 1 Bet

The test asks:

return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative.

With the code you have right now what would be returned if count was 100, but your function was sent a 7 or 'A' card?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.