javascript - != operator not working in while loop condition when combined with || OR -
i have basic while loop executing prompt's input value, running through condition. odd reason when use !== along || in same condition not work. know can add additional parameters compare against using isnan , other logical operators, makes no sense why not work , route working.
var number; { number = parseint(prompt('enter 1 or 2')); } while ((number !== 1) || (number !== 2));
if run following code single expression compare against, work no problem, in previous statement not have multiple conditions compare against.
var number; { number = parseint(prompt('enter 1 or 2')); } while (number !== 1);
thanks!
if number 1, lhs false isn't 2 rhs true , overall test true.
if number not 1, lhs true , overall test true.
you need &&
there saying if number not 1 , not 2.