This page demistrates JavaScript loops and how they can be used.

What can be used in a Loop:

Greater than
(>)
Less than
(<)
Equal to
(==)
Greater than or Equal to
(>=)
Less than or Equal to
(<=)
NOT Equal to
(!=)

Don't forget curly braces ({}) when you have more than one statement in your Loop!

Code Output
code

Example: How Loops work


Input a number between 1 and 20:

code

Example: How Loops work


code

Example: How Loops work


THE LOOP DOSE NOTHING BECAUSE CONDITIONS ARE ALREADY MET!!

code

Example: How "Break" works in Loops


THE LOOOP STOPS AT 4 BECAUSE OF THE BREAK!

*HTML code was cut off due to size

code

Example: How "continue" works in Loops


NOTICE THAT NUMBER 5 IS MISSING!!

*HTML ccode was cut off due to size

code

Example: Nested Loops


Height:
Width:

*HTML ccode was cut off due to size