5.Logical Operators


#1


Please help me to understand the next step I should take.

var user = prompt ("What does everyone call you?").toUpperCase();
switch(user) {
case 'Mariah':
console.log("What a nice name!");
break;
case 'Amora':
console.log("The name of a Goddess!")
break;
case 'Shante':
console.log("I once had a friend nanmed Shante")
break;
case 'Stella':
console.log("My Grandmother's name is Stella also. Wow.")
break;
default:
console.log("What a very unique name you have!");
}
var answer = true;
if (answer) {
console.log("I knew your name was Mariah!");
console.log("Such a great name!");
var town = prompt ("Where did you grow up, which town or city?").toLowerCase();
switch(town) {
case 'Tracy':
console.log("We may know each other");
town = true;
break;
case 'Richmond':
console.log("We've never met before");
town = true;
break;
case 'Oakland':
console.log("I am sure we've never met");
town = true;
break;
default:
console.log("Can't wait to learn more about who you are!");
town = true;
break;}
}
else {
console.log("Dammmmn"); }


Replace this line with your code.


#2

@cdethis,
Removed the to-uppercase and to-lowercase as you were not using them.....
Created a function, which get called .....

var user = prompt ("What does everyone call you?");
//.toUpperCase();
switch(user) {
  case 'Mariah':
    console.log("What a nice name!");
    var result = iHaveAmariah( true );
    if (result) {
        console.log("As you have my name\n" +
         " and are from my town \n" +
         "maybe we could meet!");
    }
    break;
  case 'Amora':
    console.log("The name of a Goddess!");
    break;
  case 'Shante':
    console.log("I once had a friend nanmed Shante");
    break;
  case 'Stella':
    console.log("My Grandmother's name is Stella also. Wow.");
    break;
  default:
    console.log("What a very unique name you have!");
}

//var answer = true; 
function iHaveAmariah( answer) {
  if (answer) {
     console.log("I knew your name was Mariah!");
     console.log("Such a great name!\n");
     var town = prompt ("Where did you grow up, which town or city?");
     //.toLowerCase();
     switch(town) {
       case 'Tracy': 
         console.log("We may know each other...\n");
         town = true;
         break;
       case 'Richmond':
         console.log("We've never met before");
         town = false;
         break;
       case 'Oakland':
         console.log("I am sure we've never met");
         town = false;
         break;
       default:
         console.log("Can't wait to learn more about who you are!");
         town = false;
         //break; not needed in the =default=
     }
     return town;
  }
  else {
      console.log("Dammmmn");
      return false;
  }
}

#3

Thanks @leonhard.wettengmx.n,
would you also check out my question regarding 5.Toss in an array?
Would be very much appreciated!