Message from JavaScript discussions

May 2019

— Need a lil help.

— 

Var ask = prompt("Do you have a name?");
while (ask!=="yes" || ask!=="yup") {
ask = prompt("Do you have a name?");
}

— When I run this code. It keeps repeating infinitely. I want it to repeat it infinitely unless a user types "yes" OR "yup", but it keeps repeating even if a user types "yes" OR "yup"

Message permanent page

— Change || to &&

— Could you please explain me why?

— While ask is not "yes" or ask is not "yup"

— Ask will always not be one of them

— It's like saying:
keep running until ask is both "yes" and "yup"

— And it can't be both at once

— If we double negate it will end up like !!(ask!==“yes” || ask!==“yup”) is the same as !(ask===“yes” && ask===“yup”) and there you are. Ask can’t be yes and at the same time yup. And because that’s always !false -> true

Message permanent page

— Https://en.wikipedia.org/wiki/De_Morgan's_laws

— Any alternative way to write this code?