How to use for loop in javascript

You can use the For Loop in javascript just like you use it in any other language.

Below is a for loop with an alert. The code is pretty self explanatory, in case of any doubts or suggestion please use the comment section below and I shall get back to you.


<script type="text/javascript">
function RunMyForLoop(count)
{
 for ( i = 0; i <= count; i++ )
{
alert( "current count is : " + i );
}
}
</script>

Demo : Click here to run the above method with a count of ‘5’

Cheers!