Can't complete this exercise without crashing the computer


#1

for (var i = 10; i >= 0; i= 2) {
console.log(i);
}

Anyone know what I'm doing wrong?


#2

The for loop works like this the first part:

var i = 10;

is executed once before anything starts.
The second part is checked before every loop and the loop only starts if it is true:

 i >= 0

it is so you loop.
The last part is now there to be executed after every loop.

i= 2

in your case it sets i to be 2 unfortunately this is again >= 0 so the condition is still true and as there is nothing done to make the condition become false it goes on an on and on till your browser refuses to work.