Google Crashing When Using "For" Loops


#1

Whenever I use any type of "for" loop, www.codecademy.com crashes and I have to exit the page then go back.


#2

Hi @coding ,

Could you post one of those for loops here, so we can take a look at it?


#3

Can we see your code? In most cases, if you work with loops, and it keeps crashing, you have a infinity loop

@geomaticmashups, you beat me too it by 3 seconds


#4

Yep, that's what I was thinking, @stetim94 ...


#5

We're stuck in an infinite reply loop ... :wink:


#6

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


#7

Just moving this topic over to the lounge :smile:


#8

yep, infinity loop. This will only temporary add 5 to i, you need to do:

for (var i = 5; i < 51; i += 5) {

i doesn't get upgrade if you do not do this


#9

Why? I think this loop is part of the exercise? You don't think so?


#10

@coding ,

Yes, it is an infinite loop. The i + 5 does not update the value of i. You need i += 5.


#11

I don't know what the "+=" means. Could you tell me what it is?


#12

yea, += is a shorthand. full out this would be:

i = i + 5

#13

Okay, thank you for helping me out with this.


#14

Oops my bad, been a long day :frowning: Thought it was a problem with google at first glance I'll move it back.


#15

No problem, the title is a bit misleading, i can understand the confusen after a long day