Introduction to For Loops - Practice Counting Down


#1


https://www.codecademy.com/courses/javascript-beginner-en-NhsaT/1/2?curriculum_id=506324b3a7dffd00020bf661


Hiya,

I keep finding that on this exercise my browser just crashes when I click save and submit. I've tried more than one browser on my laptop. The browsers are fine in all other web sites and online tasks, so I don't think it's an issue with my laptop.

Please see my code below and advise on what could be causing this issue.

Thank you :confused:


// Example of infinite loop. THIS WILL CRASH YOUR
// BROWSER. Don't run the code without changing it!

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


#2

you have an infinity loop, i++ is a shorthand for i = i + 1

if you want to get from higher to lower value, increasing by one is not a good idea


#3

Thank you for your prompt response.

The lesson does not make that aspect clear, should I increase by 2 or more then?


#4

if you want to get from higher to lower number, i wouldn't increase at all.


#5

Ah, so then you would decrease instead?


#6

I just changed my code as follows and it worked!! :joy:

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


#7