Code editor is freezing

I am working with chapter 15 (project phases of the moon). I was at the point of adding the moon’s rotation around the earth, and my code editor has frozen. I have closed my browser and restarted my computer–no change. I have tried using the /?e but still nothing. The code I was working on will show up (sometimes!), but I cannot copy any code. Help? Thanks!

Thanks for trying the ?e approach to fix. If you couldn’t find the problem in edit-only mode, I think the next step is to go back into edit-only mode and share the entire project here. I can have a look at the code and will then suggest a fix.

Either use the share option from the menu in 3DE or copy and paste it directly into your reply. The share option is less error prone. If you prefer copy & paste, be sure to paste it between 3 backtick lines:

Explain how your code is misbehaving...

// Paste your code here

Include any more information that you like here...

Once you share the code, we ought to be able to figure out the problem relatively quickly.


Here’s the code link -

I did decide to try starting again, so I created a new file and went from the beginning. That one worked, but I’m still not sure what I was doing wrong in the original file. If you can find the issue that would be great so that I can learn more!


I found the problem. It looks like it was my fault as much as anything.

The problem line is line 68:

for (var i = 0; i < 500; i)

It is supposed to be:

for (var i = 0; i < 500; i++)

It looks like you typed it perfectly right up until the ++. 3DE’s auto-save then kicked in at which point the code was run and locked the browser.

JavaScritpt for statements loop a bit of code. The line is supposed to start the variable i at zero, go as long as i is less than 500, and increase i by one (i++) each time through the loop.

But, since you never got the chance to type ++, the code is currently stuck in an infinite loop. It starts i at zero and would stop the loop if i ever reached 500. But, since the last part of the for statement is just i without changing i, i is always zero. So the code is stuck there. i is always zero and the for statement just keeps looping over and over and over – locking the page up.

I probably should have included a warning whenever for loops are used – something like you may have to go into edit-only mode if the code gets auto-saved before you finish typing. Sorry about that. But, good on you for re-doing the code and getting it working the second time through :slight_smile: