HELP! Yes is not defined!


#1

Please help-Its telling me that Yes is not defined!

var user = prompt("Is your name Charlie or Dave or Brian?").toUpperCase();
switch (user){
case 'CHARLIE':
var Charlie = prompt ("Is your name Charlie(YES or No)?").toUpperCase();
if(Charlie==='YES'|| CHARLIE==YES){
console.log("That's my favorite name!");
} else {
console.log("It must be Dave or Brian then?");
}

break;
case 'DAVE': 
var Dave = prompt ("Is your name Dave(YES or No)?").toUpperCase();
      if(Dave==='YES'&& Dave===Yes){
  console.log("That's my favorite name!");
} else {
  console.log("It must be Charlie or Brian then?");
}
break;
case 'BRIAN':
var Brian = prompt ("Is your name Brian(YES or No)?").toUpperCase();
      if(Brian==='YES'||Brian===Yes){
  console.log("That's my favorite name!");
} else {
  console.log("It must be Dave or Charlie then?");
}
break;
default: 
console.log("I'm sorry make your selection again please");

};


#2

You need to make the Yes after these into strings so put them between either ' ' or " "

var user = prompt("Is your name Charlie or Dave or Brian?").toUpperCase();
switch (user){
case 'CHARLIE': 
var Charlie = prompt ("Is your name Charlie(YES or No)?").toUpperCase();
if(Charlie==='YES'|| CHARLIE=="YES"){
console.log("That's my favorite name!");
} else {
console.log("It must be Dave or Brian then?");
}

break;
case 'DAVE': 
var Dave = prompt ("Is your name Dave(YES or No)?").toUpperCase();
      if(Dave==='YES'&& Dave==="Yes"){
  console.log("That's my favorite name!");
} else {
  console.log("It must be Charlie or Brian then?");
}
break;
case 'BRIAN':
var Brian = prompt ("Is your name Brian(YES or No)?").toUpperCase();
      if(Brian==='YES'||Brian===Yes){
  console.log("That's my favorite name!");
} else {
  console.log("It must be Dave or Charlie then?");
}
break;
default: 
console.log("I'm sorry make your selection again please");
}

This works for me.


#3

two problems in this line:

if(Dave==='YES'&& Dave===Yes){

this is not going to work, why? because now the user has to both enter YES and Yes for this to work (both condition have to be true), and since you transform the input to uppercase, you could remove Dave===Yes, which will resolve the error message you have. Your Yes in this comparison is a variable, not a string (it should be a string)