4. switch Code Your Own Adventure 2 HELP!

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
don’t know how to make a link but here is my problem:

<In what way does your code behave incorrectly? Include ALL error messages.>
It says: Oops, try again. Make sure to use a break statement with each case!
and it comes out perfect and I do have break staments? here is my code.

```

var user = prompt(“Your parents bought a new house! But you hate it! It’s your average, everyday haunted house. Dark, creepy, spider webby. And guess what! The previous owner of this creepy old place, (an eighty year old woman with cats) just died. So, you go up to your room to unpack. As you unpack, you explore! The closet, the bed, Under the bed, and the walls. BORING! So you plop on the bed and dread the next seven years before college, which at the moment, doesn’t look too shabby.
You go to you suitcase The next day, to unpack the last couple things, and you find a shirt, you’ve never seen this shirt before. So you pick it up and put it in your closet. and in the closet is something odd, you haven’t seen before, sort of like a glow. And you pull the hanging clothes back and see a door! You drop the shirt in shock! It was never there before! and you try to open it. LOCKED! You pick up the shirt and see it has unfolded, and inside was a key! you smile and…”, “Do you OPEN it, NOT, or SAVE FOR LATER, type here!”).toUpperCase();
switch(user) {
case “OPEN”:
console.log(“Take the key and insert it to the keyhole, and twist! Inside the light is blinding, then slowly fades away, in the door it looks like a forest, you are puzzled. You look into room, into the forest, room, forest, room, forest. Extremely confused, you hear something…something…Beckoning you? ‘Come. Come!’ slowly it gets louder then softer, as if it is moving back and forth. I step inside to see who it is, and the door shuts. You’re trapped!”);
break;
case “NOT”:
console.log(“Take the key, and stick it into the key hole, But before you turn it, you decide not to and shove it into your pocket. Then you fold the shirt, and put it away. But you hear a voice, coming from the door, you turn. ‘Hello?’ you ask, but still, only this you hear: 'come, open the door. Come, open the door.'with a rithmac tune to it. You can feel the key warmer in your pocket. You know it’s psychological, but you still feel it, warmer, warmer still, a bit hot, quite hot, burning! You quickaly grab the key, and insert it and twist. The door opens with a blinding light. And inside is a forest, and the voice beckons you as you try and figure out this ‘sorrcery’ of sorts, and you step inside! The door slams! You’re trapped!”);
break;
case “SAVE FOR LATER”:
console.log(“Take the key and walk out of the closet, you can’t decide to open or not, and you think you should sleep on it, you set the key on your nightstand, and plop against the pillow. you then wake up and hear something, a noise you can’t really describe. you take the key, over to the door, your heart pounding. Boomp boomp, boomp boomp, boomp boomp. you can hear it. you walk to the door, insert the key and twist, and whats behind the door…is…! And then you jolt awake! grab the key and rush to the door, insert, twist, and the thing behind the door, was nothing, exept a forest and you step inside!”);
break;
default:
console.log(“Not sure if that’s a choice, try again.”);
}

<do not remove the three backticks above>
3 Likes

I know it’s a lot of reading, but let me now if you like the story

2 Likes

Nice story, but here’s the thing…

On the that's word, the script recognizes it as the end of the log (end of the quotation marks), screwing up all the code.
It appears on all the console.log 's, fix it and the code should work properly.

2 Likes

thanks!:grinning: but it doesn’t work :disappointed: same error message

2 Likes

Hmm, so I tried your code without changing nothing and it appears to work perfectly.

Try changing browser, or contact a Codecademy Moderator.

2 Likes

I reloaded the page, closed the tab and re-opened it, and went onto internet Explorer and it still has the same message how do I contact a Codecademy Moderator

2 Likes

If you buy Codecademy Pro you can get Moderators that will answer you question in about 2 min and it takes them about 10 min to fix everything!

2 Likes

urrgh how much $!!!

2 Likes

Try to “escape” all of the quotes (with a backslash) as so:

console.log("T\'was a very beautiful mornin\', with the sun shinin\'!");
1 Like

@heammawihio, I think maybe the checker just doesn’t like how long your prompt is. If you shorten it the error goes away… (It seems like it’s ok to keep the text inside the form field too). Perhaps you can try use some confirm boxes first if you want to keep the intro length (I haven’t tested this).

However for reference, I think you’re supposed to escape new lines like “Line A \nLineB”. I could be wrong, but if you think back to the exercise where we used \ for new line escapement iirc they had to include a block of code at the top to make it work.

frisby

2 Likes

@zolated Are you sure? I don’t think it should be a problem because the string is contained in double quotes…

2 Likes

I already told that I was wrong.

2 Likes

@zolated :speak_no_evil: Sorry! I didn’t realize as sometimes code seems to run when there’s something wrong.

1 Like

THank you all SOOOO much they all really helped! I think I might have to get codecademy pro for it to work.:cry: I really appreciate the help though :grin: Thanks again

2 Likes

@heammawihio I think your program is fine… I don’t know if subscribing will help if it turns out the only issue is the lesson objective checker disliking the code and not that it is wrong…

2 Likes

I think I’ll just delete it and start it over, I’ll make a different type of game

1 Like

Good luck! Hope you’ll let us play your new game, too :slight_smile: