Counting Cards syntax error? 30:38

Tell us what’s happening:

I’m getting a syntx error message for 30:38 which is not part of the portion I am inputting. I have checked my code many times and it looks right to me.

Your code so far

var count = 0;
function cc(card) {
  // Only change code below this line
switch(card) {
		case 2:
			case 3:
			case 4:
			case 5:
			case 6:
					count += 1;
				break;
			case 7:
			case 8:
			case 9:
				count += 0;
					break;
			case "J":
			case "Q":
			case "K":
			case "A":
					count -= 1;
  return count + (count > 0 ? "Bet" : "Hold");
  
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
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/75.0.3770.142 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

Could it be that you aren’t defining count anywhere? The other potential issue might be with this line
count + (count > 0 ? "Bet" : "Hold");

The part in the parenthesis is not going to evaluate to a number, I don’t think you can add that to the count.

When I return count > 0 ? "Bet" : "Hold" without the count + the code runs for me.

I’m looking at it. I will get back to you. I checked it against someone else’s on Youtube and it worked them them using count + https://www.youtube.com/watch?v=zgs06k00YIE

Lisa, I took off “count +” and it still doesn’t work. What I have is

return (count > 0 ? "Bet" : "Hold");

I just ran it with the count + part and it worked. What is the error you’re seeing?

SyntaxError: unknown: Unexpected token (30:38)
It refers to the last line which is the numbers to be run. It seems there is a problem with the semicolon on the end. I didn’t touch that line.

Are you closing both the switch statement and the function with }?

return (count > 0 ? “Bet” : “Hold”);

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);

Would you mind sharing in a codepen? The code is running for me, I don’t see the error.

no problem. I’ll copying and paste to codepen

It’s compiling but showing me an ( undefined. I’ll check to see if I’m missing one of those but if it worked for you it should work for me. Just a second.

https://codepen.io/diane-nelson-trotter/pen/qGdJRd

This looks like a different pen

I can’t see but one line. I will try it again.

https://codepen.io/diane-nelson-trotter/pen/qGdJRd I think I hit the wrong button for tidy JS

The pen I see when I click the link is called “navigationbar”

I cleared out that code for HTML and CSS and input the Java Script. Is that wrong?

It should update. Did you save it?

just saved it. Is it ok.