Basic JavaScript - Counting Cards

Can you tell me what is incorrect about this code?

Describe your issue in detail here.

**let count = 0;

function cc(card) {
// Only change code below this line
let count = 0
if (card >= 2 && card <= 6) {
count++
} else if (card >= 7 && card <= 9) {
count = count
} else {
count–
}
if (count >= 1) {
console.log(count + " " + “Bet”)
} else {
console.log(count + " " + “Hold”)
}

return “Change Me”;
// Only change code above this line
}

cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);**

let count = 0;

function cc(card) {
  // Only change code below this line
let count = 0
if (card >= 2 && card <= 6) {
  count++
} else if (card >= 7 && card <= 9) {
  count = count
} else {
  count--
}
if (count >= 1) {
  console.log(count + " " + "Bet")
} else {
  console.log(count + " " + "Hold")
}

  return "Change Me";
  // Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A');

Your browser information:

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

Challenge Information:

Basic JavaScript - Counting Cards

Why console.log instead of return?

1 Like

Oh my goodness. Thank you for pointing that out. I know better than that. :slight_smile:

1 Like

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