javascript control structures jbwyatt.com

do while, while, for, if, switch


.. loops and branches

var currentNumber = 0; while (currentNumber <= 12) { alert(currentNumber); currentNumber = currentNumber + 2; } 0 2 4 6 8 10 12
for (var counter = 0; counter < 20; counter++) { if (counter > 15) alert(counter + "**"); else if (counter > 10) alert(counter + "*"); else alert(counter); } 0 1 2 3 4 5 6 7 8 9 10 11* 12* 13* 14* 15* 16** 17** 18** 19**

.. examples