mercredi 1 juillet 2020

javascript if statement not working in while loop

I'm not sure what's missing. I tried applying the while under the 'ifs' and 'if elses' and while won't function unless it's on top. But the initial if is the only one coming up as undefined and I can't figure out why that is? I'm newer so sorry if it's a little messy.

you like to go on, musical, tropical, or adventurous?");

switch(vacationType){
    case "musical":
        alert("Musical! Sounds nice!")
            break;
    case "tropical":
        alert("Tropical! Nice!")
            break;
    case "adventurous":
        alert("Adventure Time!")
            break;}

while(vacationType != "musical" && vacationType != "tropical" && vacationType != "adventurous") {
    vacationType = prompt("Oops! Lets try again: musical, tropical, or adventurous?");
}
if(vacationType == "musical"){
    destinatiion = "New Orleans";
}
else if (vacationType === "tropical"){
    destination = "a tropical beach vacation in Mexico";
}
else if (vacationType === "adventurous"){
    destination = "a whitewater rafting adventure in the Grand Canyon";
}```


Aucun commentaire:

Enregistrer un commentaire