Tell us what’s happening:
Ok so back to this after other day site wouldnt let me fix mistakes. Anymew so here i am doing the code but it failed. Can anyone help fix this?? Its kinda confusing still.
Your code so far
...
var count = 0;
function cc(card) {
// Only change code below this line
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count 0;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
default:
break;
return "Change Me";
// 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 (Linux; Android 5.1.1; KFDOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/77.3.1 like Chrome/77.0.3865.116 Safari/537.36.
Your switch statement is missing something right at the beginning.
Also,
case 7:
case 8:
case 9:
count 0;
count 0; is incorrect syntax.
Anyways, if card is 7, 8, or 9 you want count to stay the same. so you don’t have to do anything for those cases. Just leave them out.
well thats hard to do on mobile. And if i make a mistake i have to reset code alot. I added this
after i added the switch(val) which i forgot to add earlier on. Maybe that’ll help yall understand what the prob is. Its saying now SyntaxError: unknown: Unexpected token (35:0) with the if statement added. I feel i about got it. But not clicking for me
Without seeing the full code, we are having to guess at what is above and below the code you posted.
The only thing I can guess without seeing anything else, is you should get rid of the } after the ; in the else statement code block. Maybe you already have a } below that line that I can not see?
Fixed forgetting to add a switch(val) at beginning of code
Fixed to add if statement
Now reviewing
Your code so far
...
var count = 0;
function cc(card) {
// Only change code below this line
switch(val){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count 0;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
default:
break;
}
if (count > 0){
count + " Hold";
}else{
count + " Bet";
}
return "Change Me";
// 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');
This took a bit to get copied and pasted and written. Like i said all i added was the if statement.
you can ignore then the comment to the first quote I did (I am going to edit that message too, so you can reference just what’s there.
I add this tho:
Your switch statement is not closed.
Next time you need other hints about what else to fix please use the process above to post your code so it will be exactly what’s in your editor. Sometimes it’s one character that makes all the difference and if you don’t copy and paste exactly it is not possible to know if that is the issue or not.
This is still doing the exact same thing even after fixing it. Went thru the video for help as well and still this test wont go thru.
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++;
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
}
// 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 (Linux; Android 5.1.1; KFDOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/77.3.1 like Chrome/77.0.3865.116 Safari/537.36.