JavaScript ::

Simple For Loop

+10 JavaScript

You can't be much of a programmer if you've never written a for-loop. This is very simple to do in JavaScript. Your task is to write a for-loop and alert the current value of your "counter" variable.

There is a variable that is already defined for you - "n" - which is set to a random number. Simply write a loop that counts from "0" to, but not including, "n" and alert the value. When you've finished writing your code, click the "Run my script" button to have your results evaluated.