Crashing my browser


#1


Replace this line with your code.


#2

What is the name of the exercise?


#3

Sounds like you've created an infinite loop. If you had replaced that line with your code we could be talking about how to fix that.


#4

Intro to While Loop I added a condition as instructed and my browser crashed


#5

And why was my account placed on hold?


#6

It's automated. It's just automated along with your fist post


#7

Let's see your condition -- let's see all of your code.


#8

ahh ok so why an excercise that results in an infinite loop?


#9

If you created a loop that has no way to end itself then you have an infinite loop.


#10

yes I see that, but any condition in that code block will result in an infinite loop


#11

How do you figure that? -- give me an example.

I'm not sure which code block you are referring to here.


#12

well if you enter a condition that is true the excercise runs as an infinite loop such as 5+5===10. If you run 5+5=11 the exercise fails


#13

the only solution is to simply add the variable to the condition, which really does little to help understand how a while loop works


#14

Is this the exercise we are talking about?

https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/0/2


#15

yes that is the exercise I'm referring to


#16

Funny thing is the very next exercise actually touches on that, and explains that the condition must change. Kind of putting the cart before the horse, just saying


#17

If you are going to loop as long as that is true -- which is forever, then it makes sense that you would have created an infinite loop.

I think the creator of the exercise was hoping that you would use the understand variable that they have setup there for you.

You don't have to do that though, but you can not just put in a condition that will always be true.

You could put in something like i < 10, then you would have to set the variable before the loop starts and then inside the loop you would have to change its value so that eventually the condition was no longer true.

For one of an infinite number of possibilities:

var i = 0;
while( i < 10 ){
    console.log("I'm learning while loops!");
    i++;
}

#18

That happens sometimes :wink:


#19

Yes but that is essentially a for loop correct? I suppose I just got confused with the instructions.


#20

You could accomplish the same thing with a for loop, yes. That wasn't what you started out asking about though.

any condition in that code block will result in an infinite loop

is what you were wondering about. If you need an example that is less like a for loop:

var playAgain = "yes";
while( playAgain === "yes" ){
    console.log("I'm learning while loops!");
    playAgain = prompt("Do you want to play again?");
}

The point is, that there are infinite conditions that you could write that would not cause an infinite loop.