5/6 overdoing it on the second if statement?


#1

once again got a problem with some of my code. i hink it has something to do with my second if statement when i try to include the && statement. evertyhing apart from this piece of code works perfectly

if(where === "neverland" || "imaginationland") {
console.log (" Ok let's go to " + where);

    var how = prompt("Will you use a boat or a plane to get there?")

    if (true  && (how ==="plane") ){
        console.log("lets go to imaginationland by plane")

    }else{
        console.log ("You can't go there by boat silly");
}else{
    console.log("thats not a good destinatin")
}

the complete code i have currently is
var user = prompt("are you ready for an epic adventure?").toLowerCase();

switch(user) {
case 'yes' :
console.log("Alright where do you want to go?");
var where = prompt("Would you like to go to neverland or imaginationland?")

if(where === "neverland" || "imaginationland") {
    console.log (" Ok let's go to " + where);

    var how = prompt("Will you use a boat or a plane to get there?")

    if (true  && (how ==="plane") ){
        console.log("lets go to imaginationland by plane")

    }else{
        console.log ("You can't go there by boat silly");
}else{
    console.log("thats not a good destinatin")
}

break;

case 'no':
console.log("Go home");
break;

case 'maybe':
console.log ("you have to be sure");
break;

default:
console.log("i dont understand ");
break;
}


#2

var where = prompt("Would you like to go to neverland or imaginationland?")

if(where === "neverland" || "imaginationland") {
    console.log (" Ok let's go to " + where);

    var how = prompt("Will you use a boat or a plane to get there?")

    if (true  && (how ==="plane") ){
        console.log("lets go to imaginationland by plane")

    }else{
        console.log ("You can't go there by boat silly");
}else{
    console.log("thats not a good destinatin")
}

break;

case 'no':
    console.log("Go home");
    break;

case 'maybe':
    console.log ("you have to be sure");
    break;

default:
    console.log("i dont understand ");
    break;
}

You forgot to close your first else statement:

}else{
        console.log ("You can't go there by boat silly");
// here must be a curly bracket
}else{
    console.log("thats not a good destinatin")
}

#3

This condition is incomplete. The string "imaginationland" stands for itself, without any logical operator and a 2nd value to compare it to. As you don't have a comparison the computer can't really evaluate this string. Therefore, and this is a convention that is generally valid in javascript, the computer evaluates it as "true". The proper condition would be:

if(where === "neverland" || where === "imaginationland")


#4

didnt solve it completly but was a part of the problem indeed.
i took the if/else that was embedded in the first if statement and placed it after the firsst if/else statement. this solved the problem