...

View Full Version : Extremely Simple Question



zorg222
12-16-2005, 08:44 PM
What I want to know, is how to make a for loop go up by twos.

FE, here is my code as it is, it is going up by ones.



<script type="text/javascript">
var h=0
for(h=0;h<=50;h++)
{
document.write("The magic number is " + h)
document.write(".")
document.write("<br>")
}
</script>


I know it is controlled by the "h++" bit, unless I am missing something.

Help would be appreciated.

felgall
12-16-2005, 09:05 PM
h++ adds 1 to h. To add 2 each time around change it to h+=2



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum