7/13 error


for (var i = 10; i >= 0; i+= 1) {

whenever I try to run this, it freezes the page. I don't know why this is happening.


Well if you have an error it often helps to think through it step by step. I know tedious work but at least it shows you the problem.

So you start with this part of your for loop:

var i = 10

means your setting i to be 10. Then you check if i >= 0:

i >= 0

it sure is 10 > 0. Then you print i and after this increase i by 1:

 i+= 1

by now you might already see the problem:
I is increasing instead of decreasing meaning your condition i> 0 will always be true and therefore the loop will never stop working and even using more RAM by your browser can't solve this because it is not a matter of speed so it collapses after some time and good browsers show you a pop-up to stop the execution.

PS: This site might also be helpful:


Thank you this helped alot.