Tab freezing bug


#1

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

Whenever I hit "Save & Submit Code" during this exercise the tab freezes and becomes completely unresponsive. I've tried using three different computers and a second search engine (I've tried Firefox & Chrome), but the problem persists. Any help would be appreciated.


#2

sounds like an infinity loop, can you copy paste your code to the forum? The url will just load the exercise with my own code


#3

for (var i = 5; i < 51; i + 5) {
console.log(i);
}


#4

infinity loop, like i guessed. Look at this code:

var i = 5
console.log(i) // 5
console.log(i + 5)// 10
console.log(i) // 5
i = i + 5
console.log(i)// 10

in your code, you never update i, you just temporary add 5, but that is it.


#5

Okay, thanks.
I'll just go back and make sure it updates the value.


#6

Hi! could you explain please? I mean the code from previous lesson works okay.. and whatre #s?


#7

i mess up languages, in python there are comments :stuck_out_tongue: i changed them // which are JS comments. It just give the output, so you can just look at the code without running it


#8

Thanks! love codeCademy :+1: but why another task didn`t make infinity loop?


#9

well, its not the tasks which makes infinity loops, its your code

A small mistake is easily made, difficult to tell


#10

I meant this:


why it didn`t make infinity loop?


#11

well, the loop condition becomes false after a couple of iterations, so its not a infinity loop

the big difference is here:

i = i + 1
i + 1

you update i correctly so it becomes 24 eventually and the loop ends.

the second code (i added) will just temporary add 1 to i, the i variable never updates. Which i demonstrated with the print statements


#12

Thanks, such a silly mistake))


#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.