The Counting Cards Tutorial

Hello everyone

Just completed the counting cards tutorial, this was my solution it passed but im not sure if its 100% right??

var count = 0;

function cc(card) {
  // Only change code below this line
const string = ['J', 'Q', 'K', 'A'];
if(card > 1 && card < 7){
  count++;
} else if(card === 10 || string.includes(card)){
  count--;
}

if (count > 0) {
  return count + " Bet";
} else {
  return count + " Hold";
}
  // Only change code above this line
}

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

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hi @ItsJames !

Welcome to the forum!

I added spoiler tags around your code since it is a full working solution.


What do you mean by 100% right?

Hi jwilkins

Thank you and my apologies :grimacing:

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