Code your Adventure 2!


#1

var answer = prompt("You meet a ferocious dragon, what are you gonna do? Fight him, Run away, Trick him, Fake your death, or pay him?").toUpperCase();
var user = answer;
switch(user){
case 'FIGHT HIM':
var decision = prompt("Are you good at fighting?(yes or no)?");
var decisions = prompt("Do you have a sword and shield(yes or no)?").toLowerCase();
if(decisions === "no" && decision === "no"){
console.log("you need weapons and fighting skills!!! The dragon got you...");
} else if(decision ==="yes" && decisions === "yes"){
console.log("the dragon ran away screaming in anger and pain; YOU DEFEATED THE DRAGON!!!");
} else if(decision ==="yes" && decisions === "no"){
console.log("treaty!!!");
} else if(decision ==="no" && decisions === "yes){
console.log("treaty!!!");
} else{
console.log("you don't have anything?, you just got maimed.");
}
break;
case 'ESCAPE':
var vehicle = prompt("Do you have a vehicle with you?").toLowerCase();
var vehicleYES = prompt("Which vehicle do you have?").toLowerCase();
var car = prompt("How fast can it go?").toLowerCase();
if(vehicle === "yes"){
if(vehicleYES === "car"){
if(car === "really fast"||"fast"){
console.log("you got away with half of your car torn off!!");
} else{
console.log("the dragon got you and your car!");
}
} else if(vehicleYES === "plane"){
console.log("The plane is on max power, and you speed away, hoping to never come back again, after that close call!!!");
}
} else{
console.log("Once you realize you don't have a vehicle, it came to mind that this is the end of the road...");
}
break;
case 'TRICK HIM':
var trick = prompt("Are you smart?").toLowerCase();
var understand = prompt("Do you know what is the dragon's mental weakness?").toLowerCase();
if(trick === "yes" || "sort of" && understand === "yes"){
console.log("the dragon became your friend!!!")
} else if(trick === "no" && understand === "not really"){
console.log("the dragon tortures you over and over!!!");
} else{
console.log("nothing?, the dragon captured you!");
}
break;
case 'FAKE YOUR DEATH':
console.log("Your Lucky!!! The dragon wasn't hungry today, so you just escaped with your limbs intact!");
break;
case 'PAY HIM':
var money = prompt("What form of money is the money you're giving to the dragon?").toLowerCase();
var request = prompt("'How much money are you going to pay?'the dragon asks");
if(money === "golden drachmas"||"dragon money" && request > 1000000){
console.log("The Dragon Smiled, and flew away, roaring in triumph for the money he received, but at least you survived!!");
} else {
console.log("The Dragon steals all of your money and sells you to the Dragon Market.");
}
break;
default:
console.log("You're so scared you can't even move? To bad, GG for life!!");
};

This Always says SyntaxError: Unexpected Token Illegal, can someone explain what's wrong???


#2

Hey @codeplayer66523,

Just so you know, I want to tell you that when it says "Unexpected token ILLEGAL", I look at the quotation marks, for one missing makes a mistake. Look at the one here I had found:

See it? Yeah, the "yes" is the problem there, forgot a quotation mark. :smiley:


#3

oh!!! didn't notice that... :blush:
thx!!!


#4

I need help with this as well :wink:
var user = prompt("You are walking along, minding your own business when suddenly everything around you changes into rocks and bricks and apes?").toLowerCase();

switch(user) {

case 'run':
console.log("You chicken!! You got away, but will wonder the rest of your life!");
break;

case 'investigate':
var openDoor = prompt("It appears to be made of wood. There is a door on it and it's locked, do you try to open it anyway? ").toLowerCase;
var lockPick = prompt("Do you know how to pick a lock? ").toLowerCase;
if(openDoor && lockPick === "yes"){
console.log("Suddenly the door whips open and a disheveled, unkempt mid-30s man appears in the doorway. 'Stop trying to break into my Box!' he bellows and slams the door in your face.");
} else {
console.log("Best to leave things you don't understand alone....");
}
break;

case 'hide':
var hidingSpot = prompt("Is there a good place for you to hide near?").toLowerCase;
var hidingSkill = prompt("Are you good at hiding?").toLowerCase;
if(hidingSpot || hidingSkill === "yes"){
console.log("You've succesfully hidden yourself, but from what or for how long....the world may never know!");
}
else {
console.log("You're unable to hide, so you turn around and book it out of there!");
}
console.log("IT was all a dream")


#5

Sorry for the late response, hadn't been looking at the unread section lately.

I think you should have solved it by now, but if you haven't can you tell me your error message?


#7

It says unexpected token {


#8

Found it. You need an extra bracket of this: }

At the end, because you have to cover this up with }.


#9

I'm still not sure i that is it...