Jason Castillo Jason Castillo - 1 year ago 125
Javascript Question

Do/while loop not working?

Here's the code:

do {
var selection=prompt("Enter password","");
} while(selection!="pass"||selection!="winner");

I'm trying to allow both "pass" and "winner" as a password for the prompt, but something goes wrong around the
, because the code works without it. I feel like the answer is right under my nose but I can't find it

Answer Source

It is hard for a single string to equal both "pass" and "winner" at the same time.

You probably want && instead of ||.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download