Logical operators


#1

*So my code works just wondering why when i put an answer in it still prints out the default*

var user = prompt("What's you're favorite hobby?").toUpperCase();

switch(user) {
    case 'Surfing':
        console.log("Hang loose bruddah!");
        break;
    case 'Hiking':
        var Hiking = prompt("Would you like to go Hiking with me?, (Yes or No)").toUpperCase();
        var Place  = prompt(" Would you like to go hiking at Havasu Falls?, (Yes or No)").toUpperCase();
        if(Hiking === 'yes' && Place === 'yes') {
            console.log("Let's go!");
        } else {
            console.log("Maybe another time");
        }
        break;
    case 'Traveling':
        var Hawaii = prompt("You eva been Hawaii? (Yes or No)").toUpperCase();
        var bumbai = prompt("You like go? (Yes or No)").toUpperCase();
        if(Hawaii === 'yes' || bumbai === 'yes') {
            console.log("Cheehu we go!");
        } else {
            console.log("Shoots den");
        }
        break;
    default:
        console.log("Oh very nice");
};


#2

You convert the user input to uppercase.

var str = "Hello World!";
var res = str.toUpperCase();
console.log(res);

The code above will result in HELLO WORLD!.
I think you know what to do from here.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.