Build a Card Counting Assistant - Build a Card Counting Assistant

Tell us what’s happening:

hello whats wrong with my code,i think i put the return inside the function

Your code so far

let count = 0;
function cardCounter (card) {
  if (card >= 2 && card <= 6) {
    count++;}
else if (card === 10 || 
card === "J" ||
card === "Q" || 
card === "K" || 
card === "A") {count--;}
}
if (count > 0) {
  return count + " Bet";
} else {
  return count + " Hold";
}

Your browser information:

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

Challenge Information:

Build a Card Counting Assistant - Build a Card Counting Assistant

Hi @iman12

There is a message in the console.

SyntaxError: unknown: 'return' outside of function. (12:2)

  10 | }
  11 | if (count > 0) {
> 12 |   return count + " Bet";
     |   ^
  13 | } else {
  14 |   return count + " Hold";
  15 | }

Happy coding

Thanks for helping me…

1 Like