# Code editor is freezing

**URL:** <https://talk.code3dgames.com/t/code-editor-is-freezing/529>\
**Category:** Uncategorized\
**Created:** [July 26, 2022, 3:21am UTC](https://talk.code3dgames.com/t/code-editor-is-freezing/529 "2022-07-26T03:21:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pickle](https://talk.code3dgames.com/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@pickle](https://talk.code3dgames.com/u/pickle)\
**Post date:** [July 26, 2022, 3:21am UTC](https://talk.code3dgames.com/t/code-editor-is-freezing/529/1 "2022-07-26T03:21:02Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![chris](https://talk.code3dgames.com/user_avatar/talk.code3dgames.com/chris/32/5_2.png) [@chris](https://talk.code3dgames.com/u/chris)\
**Post date:** [July 26, 2022, 3:45am UTC](https://talk.code3dgames.com/t/code-editor-is-freezing/529/2 "2022-07-26T03:45:49Z")

</div>

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.

-Chris

---

<div class="post-metadata">

**Author:** ![pickle](https://talk.code3dgames.com/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@pickle](https://talk.code3dgames.com/u/pickle)\
**Post date:** [July 26, 2022, 10:43pm UTC](https://talk.code3dgames.com/t/code-editor-is-freezing/529/3 "2022-07-26T22:43:05Z")

</div>

Here’s the code link - [https://is.gd/IU2oXn](https://is.gd/IU2oXn)

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!

Thanks.

---

<div class="post-metadata">

**Author:** ![chris](https://talk.code3dgames.com/user_avatar/talk.code3dgames.com/chris/32/5_2.png) [@chris](https://talk.code3dgames.com/u/chris)\
**Post date:** [July 27, 2022, 11:56am UTC](https://talk.code3dgames.com/t/code-editor-is-freezing/529/4 "2022-07-27T11:56:32Z")

</div>

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

The problem line is line 68:

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

```

It is supposed to be:

```auto
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 🙂

-Chris
