Basic JavaScript - Counting Cards

I watched the video and copy + pasted the answer that he typed and its not working.

Disclaimer I have absolutely no idea whats going on with this :joy:

Your code so far

let count = 0;

function cc(card) {
  // Only change code below this line
switch(card) {
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
			count++;
			break;
		case 10:
		case “J”:
		case “Q”:
		case “K”:
		case “A”:
			count--;
			break;
}

	var holdbet = “Hold”
	if (count > 0) {
		holdbet = “Bet”}

	return count + “ “ + “holdbet”;


  // 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

okay that is an interesting strategy.
Are you posting because you want to see a check-mark or are you posting because you want to learn something about javascript?

If the first case, please google the answer, I’m sure you can find one somewhere just so you can say you have done it.

If you want to learn to code, please go back to the exercise, erase everything you copied, and try yourself.
You can also ask us to explain something you have read if that is something you need.

hope this helps

1 Like

why even reply at that point? of course im just looking for the answer. Im going to end up learning all this through exercises in the future. If youre going to just try and troll peoples’ posts, just log onto twitter.

I recommend against this. Typically people who do this struggle more and more as the challenges progress.

We won’t (and can’t) write the answer out for you.


Your quotation marks here are wrong. You are using ‘smart quotes’ but you need regular quotation marks.

Why do you have quotation marks here?

i thought single quotes and double quotes are the same thing? at least thats what the previous instructions have said.

Single and double quotes will both work. ‘smart quotes’ will not work. ‘smart quotes’ are a specific type a double quotes that look different than ""

See how yours are tilted?

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