Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

While loop with Or statement

Not applicable
Is it possible to have a while loop with the or (||) comparison.

I've been trying while (x != 1 || 2) and variations such as while (x != 1 || x != 2).

When I have just one statement the loop performs as normally, but when I add the second argument it seems to become an infinite loop, I've tested to make sure the variable is updating so I'm pretty sure the problem lies in my loop statement.

I am fairly new to javascript so this might be a case of me trying to use features from other languages that arent available in javascript.

Thank you

14 Replies