5 (Logical Operators) PLEASE HELP


#1

var user = prompt("What is your name?").toUpperCase();
switch(user){

case'Jason':
    if(Jason.length <10 && 4>2){
    console.log("Your a legend");
    }
    else{
        console.log("Your &#9632;&#9632;&#9632;&#9632;");
    }
    break;

case'Michelle':
    console.log("She is a hottie");
    break;

case'Craig':
if(Craig.length<10 || 4>3){
console.log("You are my brother");
}
else{
console.log("You are def my bro");
}
break;

default:
    console.log("Who are you?");




}

#2

Hi @digitalslayer84339

There is two mistakes in your code :

  • You have to write your case in UpperCase because the user prompt will
    be in UpperCase with the method
  • In your if condition you have to put the variable "user", Jason or
    Craig aren't variables

Finally, your code looks like :

var user = prompt("What is your name?").toUpperCase();

switch(user){
    case'JASON':
        if(user.length < 10 && 4 > 2){
            console.log("Your a legend");
        }else{
            console.log("Your &#9632;&#9632;&#9632;&#9632;");
        };
    break;

    case'MICHELLE':
        console.log("She is a hottie");
    break;

    case'CRAIG':
        if(user.length < 10 || 4 > 3){
            console.log("You are my brother");
        }else{
            console.log("You are def my bro");
        };
    break;

    default:
        console.log("Who are you?");
};

Hold on :wink:


#3

This how your syntax should look

var food = prompt("What's your favorite foods?");

switch(food) {
case 'potato':
if( '' || '') {
console.log("!");
} else {
console.log("");
}
break;
case 'peas':
if('' && '') {
console.log("");

} else {
console.log("!");
}
break;
case 'cornbread':
if( '' || '') {
console.log("");
} else {
console.log("!");