This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Joseph Turbin
about 11 years

Make sure to use a break statement with each case!

Hello. I keep getting the error in the title above. I have a break in each case and don’t know why it’s not letting me pass the excersize. Can you help please? Thanks!! btw.. don’t judge my crappy story line. I’m not very creative. ha :)

var user = prompt("You get a call from the police. They want you to come down to the station to discuss a recent case they've been working on. Do you GO, RUN, or HIDE?").toUpperCase();

switch(user){
case 'GO':
    console.log("Great job! Now you're locked in a cell");
    break;
case 'RUN':
    console.log("You must be an idiot to run from the cops. You're in jail for a long time now!");
    break;
case 'HIDE':
    console.log("Great! They called in the dogs. Now you're really in for it! You might need to RUN!");
    break;
default:
    console.log("That wasn't an option dummy. You can't play anymore!");
}

Answer 51392a57ed1bc5fdfc000072

1 vote

Permalink

I am having the same exact issue, no idea why it’s doing that. Don’t worry about how creative you are i didn’t put any creativity into mine lol. I would also like to see an answer for this issue whether the site is glitched or the syntax is wrong.

points
Submitted by phaticus
about 11 years

3 comments

Joseph Turbin about 11 years

It REALLY seems like the site is glitched. I’ve been over this code like 100 times. With that being said.. sometimes it’s as easy as a stupid ; in the wrong place. Who knows. SOMEONE HELP US!!!!

Joseph Turbin about 11 years

Just wanted to update you in case you’re still having the same problem. You need a break on the default case. I swear I tried this once and it still wouldn’t let me pass… but I guess not. Hope you’re stuff is going well!

Even i struck hear its continuously saying …… Oops, try again! Make sure to use a break statement with each case!

Answer 513c8376130dbabf71006911

0 votes

Permalink

I change some of your program,it runs.But I do not know the reason. var user = prompt(“You get a call from the police. They want you to come down to the station to discuss a recent case they’ve been working on. Do you GO, RUN, or HIDE?”);

switch(user){ case ‘GO’: console.log(“Great job! Now you’re locked in a cell”); break; case ‘RUN’: console.log(“You must be an idiot to run from the cops. You’re in jail for a long time now!”); break; case ‘HIDE’: console.log(“Great! They called in the dogs. Now you’re really in for it! You might need to RUN!”); break; default: console.log(“That wasn’t an option dummy. You can’t play anymore!”); break; }

points
Submitted by chenjing
about 11 years

Answer 513ccc8378c6a5bc5700109e

0 votes

Permalink

Same as everyone else really, been through ti and see no errors. I had the same issue with mine! It almost seems like once you get the syntax error there is no way to fix it and have it let you pass. I just copied the code above from chenjing and it worked fine. Identical layout to my previous code…

points
Submitted by Ian
about 11 years