Why is my code not going through?



Once I press the Save and submit button, it won't do anything else. It says it already has finished loading. I tried this on two different computers and it happened on both. Do you think both of them are messed up or is there something wrong with my code? Please help!

var understand = true;

while( 5 <= 10 ){
	console.log("I'm learning while loops!");
	understand = false;


You created an infinite loop with your while condition. You assigned true to understand in the 1st line. That is unaffected by your condition. Changing understand to false in your loop doesn't affect (5<=10). It only assigns a new value to understand.

You need to input a condition that will be affected by changing understand to false.


Thank you so much!

So what would you put instead if you were to get the code working?


What was the reason you assigned true to understand?


It was set like that already. I tried fixing it, but it froze up again. I tried changing the while loop and it ran through but said to check my syntax.


Can you post the code you have?

Think about this for your loop. If you are changing the value of understand after your console.log statement runs to make the loop stop, what could you use as the condition to make the loop initially run?


I changed it to this...

var understand = true;

while( 5 == 10 ){
console.log("I'm learning while loops!");
understand = false;

It says, "Oops, try again. It looks like you didn't print the string to the console. Check your loop syntax!"


Put the variable in the loop condition, run the loop, see what happens.


Thank you so much!!! I fixed it and it ran through.
Even if it did go through, can you see if this looks right please?

var understand = true;

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

Thank you again.


What's more important than the code looking right is understanding the while loop :slight_smile:


Thank you so much! All of this helped me understand while loops. It has been coming to me much easier now. :smile: :clap:


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