5.) Brad is not defined


Not sure how Brad is not defined when you type Brad into the question that asks what your name is. All others work so I assume it has something to do with my if/else statement. Can't really find the problem so yeah need some help!

var user = prompt("What is your name").toUpperCase();
switch(user) {
        console.log("That is my name too!");
        } else {
        console.log("Your name is close to my name!");
        if (Brad||Braden){
        console.log("That is my name too!");
        } else {
        console.log("Our names are very close!");}
        console.log("I know a guy named that too!");
        console.log("You have a pretty cool name");
        console.log("That is a great name!"); }


this line:


Brad is a variable. Which doesn't exist. Either create a Brad variable, or use a string. And i am not sure what you are comparing it with.


I have looked at a few other examples under the Q/A section for Code My Adventure 2 and that format has not been a problem for others so I am not sure why the case is different here. In either case, I do not believe using a string is required or creating Brad as a variable since the lesson does not lead one to do either of those so it must be something else


yes, if you enter Brad into the prompt, it stores a string Brad into your user variables, but on this line:


you use variables (Brad and stew) which do not exist. Brad and Stew are undefined variable. The problem is in those lines. Brad is a string stored in the user variable, brad is not a variable!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.