Jason Castillo Jason Castillo - 3 months ago 18
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
||selection!="winner"
, because the code works without it. I feel like the answer is right under my nose but I can't find it

Answer

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

You probably want && instead of ||.

Comments