Code your own adventure 5/6 why won't this code work?


#1

I'd love to know why this don't work!

var user = prompt("You're paddling towards a big wave breaking in front of you. Do you DIVE under, PANIC or try to RIDE it?", "Dive").toUpperCase();
switch(user) {
case 'DIVE':
var sharkAttack = prompt("You dive under and see a shark, do you FOLLOW or ATTACK it?","Attack").toUpperCase();
if (sharkAttack === 'FOLLOW') {
console.log("You follow the shark until it dives too deep.");
} else if (sharkAttack === 'ATTACK') {
console.log("You attack the shark and it eats your face.");
} else {
console.log("Come again?");
}
break;
case 'PANIC':
var loseIt = prompt("You lose it and panic, the wave eats you up and your leash breaks, do you attempt to FIND your board or SWIM back to shore?", "Swim").toUpperCase();
if (loseIt === 'FIND'||loseIt === 'SWIM'); {
console.log("You're stuffed either way.");
} else {
console.log("You thought about it for too long and drowned.");
}
break;
case 'RIDE':
var barrel = prompt("You take off and the wave begins to barrel, will you wipe out?", "No").toUpperCase();
var barrel0 = prompt("Will you make a CUT back or a TURN?", "Turn").toUpperCase();
if (barrel === 'NO' && barrel0 === 'CUT') {
console.log("You were too slow in making your cut back and the wave closed out");
} else {
console.log("You wiped out");
}
break;
default:
console.log("Sorry, I didn't catch that, try again!");
}


#2

-You're missing a break after your default choice!

if (barrel === 'NO' && barrel0 === 'CUT') { //Line 27
                             ^

-You've added a '0' that shouldn't be there!

I couldn't see anything else right away, but let me know if that works!


#3

Comma between prompt() texts:

...or try to RIDE it?","Dive")...
...do you FOLLOW or ATTACK it?","Attack")...

See if by deleting those your code runs (I only gave you two examples, find the others).