5. Logical Operators


#1


I am super confused.
Please explain to me what I'm doing wrong.
Thanks xD

var name = false;
var user = prompt ("What does everyone call you?").toUpperCase();
switch(user) {
    case 'Mariah':
        console.log("What a nice name!");
        var answer = true;
            break;
    case 'None':
        console.log("The name of a Goddess!");
        var answer = false; 
            break;
    case 'Shante':
        console.log("I once had a friend nanmed Shante");
        var answer = true; 
            break;
    case 'Stella':
        console.log("My Grandmother's name is Stella also. Wow.");
        var answer = true;
            break;
default:
    console.log("What a very unique name you have!");
            break;
}
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 ("Perhaps you are from another Country?"); 
}

if (name && town) {
    console.log("This is interesting");
}
else {
    console.log("Starting off fresh, welcome!");
}

if (name || town) {
    console.log ("Shout out");
}
else {
    console.log("Send a letter");
}


`


#2

The entire block above. should be move into the if block directly above it


#3

Hmmmm....

var name = false;
var user = prompt ("What does everyone call you?").toUpperCase();
switch(user) {
case 'Mariah':
console.log("What a nice name!");
var answer = true;
break;
case 'None':
console.log("The name of a Goddess!");
var answer = false;
break;
case 'Shante':
console.log("I once had a friend nanmed Shante");
var answer = true;
break;
case 'Stella':
console.log("My Grandmother's name is Stella also. Wow.");
var answer = true;
break;
default:
console.log("What a very unique name you have!");
break;
}
if (answer) {
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 ("Perhaps you are from another Country?");
}

if (name && town) {
console.log("This is interesting");
}
else {
console.log("Starting off fresh, welcome!");
}

if (name || town) {
console.log ("Ayeee!");
}
else {
console.log("Wooow");
}
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();
}


#4

Found the entire solution!

Thanks @rydan
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("Confounded!"); }
if (answer||town) {
console.log("At least you live in California!");
}
else {
console.log("Are you from California?");
}
if (answer&&town) {
console.log("Where would you like to vist?");
}
else {
console.log("Where else would you like to visit?");
}