This lesson doesnt make sense to me


#1


I'm on the code your own adventure topic where we are asked to use more if/else AND some $$ || operators.


This is the lesson I am referring to:


I'm not getting error messages, and it works as expected. I just dont understand WHY I would want to write this && || statement the way I did

Below is just a snippet of my code, no erros recieved.
I just want some clarification on why I would want to put, in this example, a && and then ask about EARTH. We are in case EARTH, so of course, that one is a given.
Maybe what I wasnt realizing is I should be asking another question to the user. I have "Are you sure you're ready?" I guess it would work much better to also ask something like "Do you have any experience with magic?" Then I could have a more meaningful && or || if else statement.

ok, now I feel like I'm just thinking outloud, but I feel a lot better... I'm debating deleting this, since I feel that I've answered my own question, but I'm also thinking maybe someone is having the same stuggle as me, so I should leave it?

var user = prompt("Welcome to the school of Magic. Do you choose Earth, \ Wind, Water, or Fire?").toUpperCase();

switch(user) {
    case 'EARTH':
        confirm("Great choice! Nothing as sure as the ground beneath your \ own two feet!");
        var ready = prompt("are you sure you're ready?").toUpperCase();
            if(user === "EARTH" && ready === "YES") {
                comfirm("Let us begin.");
            } else {
                confirm("You are not ready.");
            };
    break;


#2

I'm glad you left it I was having a very similar problem that your thinking out loud helped solve.


#3

you wrote your own code.so you can better know what do you want .

what i see your code doesnt make any sense.
here

if(user === "EARTH" && ready === "YES") {
                comfirm("Let us begin.");
            }

in the case of EARTH you are checking if( user === "EARTH").
ofcourse he/she is.you already know he/she choosed EARTH (case 'EARTH':).

and
comfirm("Let us begin."); // typo //should be confrim

yeah.you could ask :slight_smile:


#4

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