Logical Operators || and &&


#1

I will paste my code here. The editor gives me an error msg about a problem with &&. Anyone see errors, punctionation, caps, anything?

`var user = prompt("How much do you want to win the lottery? A lot, A little, or Not Sure?").toUpperCase();

switch(user){
case "A LOT":
var luck = prompt("Luck is on your side! Do you want it?").toUpperCase();
if(luck==="YES"){
console.log("Let's begin.");
} else {
console.log("OK. Let's wait 5 min.");
}

    break;
case "A LITTLE":
    var scared= prompt("Are you afraid to lose?");
    if (scared==="YES"){
    console.log("OK.  Maybe a friend can play.");
    }else {
        console.log("OK.  Let's start then.");
    }
    break;
case "NOT SURE":
    var  excited = promt("Are you Serious or  Ready?").toUpperCase();
    var money= prompt("Are you poor or rich?").toUpperCase()
    if( (excited==="SERIOUS" || excited==="READY")) && (money==="RICH")
    { console.log("You're going to win!!!");
    }else{
        console.log("You can't win that way.");
    }
     break;
default:
        console.log("Ready");

};

`


#2

You're only using that operator in one place, so that tells you where to look!

You might want to create a simpler version of using && to compare with.


#3

@mccbjnn Looks like you closed the parentheses too soon.

Instead of:

if ((excited === "SERIOUS" || excited === "READY")) && (money === "RICH")

it should be

if ((excited === "SERIOUS" || excited === "READY") && (money === "RICH"))

Make sense?


#4

Yes....thanks will give it a try.


#5

That did it, thanks.