2. While Syntax. Having technical issues- "freezes" and won't let me move on


#1


Every time I press the Submit button, the pointer becomes unresponsive. The pointer itself moves, but nothing registers - not even the "Q&A Forum" and "Glossary" buttons- so I would have to exit out of the screen every time. I've been having this issue for 3 days now and I tried re-logging in, turning computer on/off, etc, but nothing seems to change it. How can I fix this? I feel like I'm the only one with this issue.

For what it's worth, the PC I'm using is only 6 months old and hasn't had any problem in the past. Someone please help! It's really frustrating being stuck due to a technical issue and not being able to move on


Replace this line with your code.


#2

Hi @crawfishmonster ,

Post your code so we can take a look it.

Might you have an infinite loop?


#3

I don't have one bc I don't understand what to do. That's why I tried pressing Submit to maybe get a hint. Below is the default code given in the beginning of the lesson

var understand = true;

while ("I'm learning while loops!") {
console.log("I'm learning while loops!");;
understand = true;
}


#4

You have this ...

while ("I'm learning while loops!") {

Therefore the condition that controls the loop is "I'm learning while loops!". That is considered to be equivalent to true as a condition, so the loop never terminates.

Change it to ...

while (understand) {

Then, when understand becomes false, the loop can terminate.

Inside the loop you need this, to make that happen ...

understand = false;

This must be removed from the loop ...

understand = true;

This might fix it.


#5

It works, thanks! I have 2 questions: is it viable to have both "understand = true" and "understand = false" in the code rather than removing "understand = true"? I tried both ways and they both work, so I'm kind of confused.

Also, does your system glitch too when you press the Submit button with having just the default code, or is it just on my end? It's bugging me more than it should tbh lol


#6

Before the loop, you need to set understand to true.

Within the loop , you need to set understand to false.

So, yes, you need both.

Codecademy might let you get away with removing the first statement, where you set it to true, but that is incorrect JavaScript, because your loop header would be testing the value of understand before you defined it. However, Codecademy complicates things by remembering the values of variables in between submissions, which can sometimes give strange results. If you suspect that this has happened, you can refresh the page to make Codecademy forget those previous values of variables.

For this exercise it gets stuck if I put in a condition that never becomes false. However, if the parentheses are left empty, Codecademy says ...

Oops, try again. There was a problem with your syntax.


#7

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