Please tell me what's wrong with my code!


#1
var user = prompt ("Choose your fate wisely. Do you accept this responsibility? Is it YES, NO ,MAYBE").toUpperCase();

switch (user) {
case 'YES':
var road less taken = prompt("Will you travel the road less taken.(YES OR NO)").toUpperCase();
var confident = prompt("Are you confident in your skills.").toUpperCase();
if (road less taken==='YES' && confident==='YES') {
console.log("This is the way for you");
}
else {
console.log("NO HALF-HEARTED EFFORTS");
}
break;
case 'MAYBE':
var road less taken = prompt("Will you travel the road less taken. (MAYBE, MAYBE NOT)").toUpperCase();
var confident = prompt("Are you confident in your skills").toUpperCase();
if (road less taken==='MAYBE' || confident==='MAYBE') {
console.log("You just might survive this. Stranger things have happened!");
}
else {
console.log("Blind faith eh!!");
}
break;
case 'NO':
console.log("Reconsiders why they left home. Goes home.");
break;
default:
console.log("Select YES, NO, or MAYBE. Anything else is irrelevant.");
}

I keep getting unexpected identifier


#2

when you name a variable, it needs to be "one word", by that I mean that you cannot have space in the name.
So /var road less taken/ should be /var road_less_taken/ for example
then don t forget to replace it in the if statment as well :smile:


#3

Thanks a lot. Gave me quite the headache.


#4

n/p :smile: haha I'm sure it did.