开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜