REFERENCE ERROR: yes is not defined!


#1

I am working on the code your own adventure two and I have tried many things but I keep coming back to the reference error: yes is not defined. How do I define yes? Thank you!

 var user = prompt("You are walking downtown when you run into an old friend.  Do you FIGHT, ESCAPE, or GREET your old friend?").toUpperCase(); 

switch(user) {
    case 'FIGHT':
        var fight = prompt("Are you willing to hurt this person?").toUpperCase(); 
        var skill = prompt("Do you know how to fight?").toUpperCase(); 
        if (fight == YES && skill == YES) {
            console.log("You are very prepared and, for whatever reason, you attack your old friend.  What did they ever do to you?"); 
        }
        else {
            console.log("You are uncapable of fighting your old friend, so they make the first move and attack you.  You lose."); 
        }
        break; 
    case 'ESCAPE':
        var run = prompt("Are you fast?").toUpperCase(); 
        var start = prompt("Do you have a head start?").toUpperCase(); 
        if (run == YES || start == YES) {
            console.log("You only needed one, so you have an advantage and you are able to quickly escape from your old friend."); 
        }
        else {
            console.log("You are neither fast nor do you have a head start, so your friend quickly overtakes you.  You lose."); 
        }
        break; 
    case 'GREET':
        var social = prompt("Are you a social person?").toUpperCase(); 
        var good = prompt("Are the two of you good friends?").toUpperCase(); 
        if (social == YES || good == YES) {
            console.log("You start chatting and catch up on old times.  The two of you decide to meet up again very soon."); 
        }
        else {
            console.log("You are very awkward and call your old friend by the wrong name.  They get very offended and walk off.  You lose."); 
        }
        break; 
    default:
        console.log("Please reanswer, this time typing only FIGHT, ESCAPE, or GREET.  Thank you."); 
        break; 
}

#2

Take a look at this, you need to make sure that YES is a string, otherwise that is taken as a variable which hasn't been defined. Make sure you do that throughout all your code. I'd stay away from using full uppercase, choose something to stick to :smile:

Let me know if that makes sense, barely made sense to me - I need some more coffee.


#3

thank you so much!! that helped a lot and i finished the segment!