JavaScript for loop help
I'm new to JavaScript and programming in general (although I know some people don't consider JavaS开发者_如何学Gocript to be a full programming language; I think it is since it has some OOP tendencies).
I am having trouble understanding for
loops.
I'm sorry this is so basic, so please don't condescend.
I have this script:
var total = 0;
for(i = 0; i < 2; total+=100)
{
document.write("The sum is " + total);
}
But, my browser window locks up and it doesn't write anything to the browser window.
What am I doing wrong?
You're forgetting to increment i
.
精彩评论