Java Script


#1

what is wrong with my code?

var user = prompt("You are running errands one day when you happen upon a secret garden. You look and see that there is a gate that is locked blocking your entrance. You must now decide to run away and forget what you saw, keep waiting to see if someone comes by to open it, or break the lock!").toUpperCase();
switch(user) {
case 'break the lock':
var fast = prompt("Somebody yells what are you doing!? So you start running, are you fast? "YES or NO").toUpperCase();
var agile = prompt("You'll have to run through the tall prickely weeds! Are you very agile?", "YES or NO").toUpperCase();
if(fast === 'YES' && agile === 'YES') {
console.log("Good job, You made it and found the golden orchid! You win!");
}
else {
console.log("Oh no! They caught up with you! You got arrested! You lose!");
}
break;
case 'keep waiting to see if someone comes by to open it':
var Patient = prompt("Patient?", "YES or NO").toUpperCase();
var wait = prompt("Do you have time to wait?", "YES or NO").toUpperCase();
if(Patient === 'YES' || Do you have time to wait? === 'YES') {
console.log("Thats alright you only need to be one of them! Somebody eventually opened the gate and you found the golden orchid! You win!");
}
else {
console.log("You are not very patient and don't have time to wait, nobody comes and you have to leave and go home. You lose!")
}
break;
case 'run away and forget what you saw':
var regret = prompt("Do you regret your decision?", "YES or NO").toUpperCase();
var back? = prompt("Do you want to go back?", "YES or NO").toUpperCase();
if(Do you regret your decision? === 'YES' || Do you want to go back? === 'YES') {
console.log("Then turn around and refresh the page!");
}
else {
console.log("Well that's ok, just go home then.");
}
break;
default:
console.log("Thats not a choice! Try again but this time choose run away and forget what you saw, keep waiting to see if someone comes by to open it, or break the lock");
}


#2

var user = prompt("You are running errands one day when you happen upon a secret garden. You look and see that there is a gate that is locked blocking your entrance. You must now decide to run away and forget what you saw, keep waiting to see if someone comes by to open it, or break the lock!").toUpperCase();
switch(user) {
case 'break the lock':
var fast = prompt("Somebody yells what are you doing!? So you start running, are you fast? "YES or NO").toUpperCase();
var agile = prompt("You'll have to run through the tall prickely weeds! Are you very agile?", "YES or NO").toUpperCase();
if(fast === 'YES' && agile === 'YES') {
console.log("Good job, You made it and found the golden orchid! You win!");
}
else {
console.log("Oh no! They caught up with you! You got arrested! You lose!");
}
break;
case 'keep waiting to see if someone comes by to open it':
var Patient = prompt("Patient?", "YES or NO").toUpperCase();
var wait = prompt("Do you have time to wait?", "YES or NO").toUpperCase();
if(Patient === 'YES' || wait === 'YES') {
console.log("Thats alright you only need to be one of them! Somebody eventually opened the gate and you found the golden orchid! You win!");
}
else {
console.log("You are not very patient and don't have time to wait, nobody comes and you have to leave and go home. You lose!")
}
break;
case 'run away and forget what you saw':
var regret = prompt("Do you regret your decision?", "YES or NO").toUpperCase();
var back = prompt("Do you want to go back?", "YES or NO").toUpperCase();
if(regret === 'YES' || back === 'YES') {
console.log("Then turn around and refresh the page!");
}
else {
console.log("Well that's ok, just go home then.");
}
break;
default:
console.log("Thats not a choice! Try again but this time choose run away and forget what you saw, keep waiting to see if someone comes by to open it, or break the lock");
}


#3

@jessicaannbrady,

-1

Change your
'switch(user) {

into
switch(user.toLowerCase()) {

-2

In several of your prompt()-statements you are forgetting a comma-,
with which you separate the text and the default
https://developer.mozilla.org/en/docs/Web/API/Window/prompt

-3

Have a close look at

if(Patient === 'YES' || Do you have time to wait? === 'YES') {

-4

back?

-5

if(Do you regret your decision? === 'YES' || Do you want to go back? === 'YES') {


#4

it still wont run, not sure why it wont work still?