# So my code broke again?

**URL:** <https://forum.makecode.com/t/so-my-code-broke-again/10534>\
**Category:** Arcade\
**Created:** [October 22, 2021, 1:03am UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534 "2021-10-22T01:03:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [October 22, 2021, 1:03am UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534/1 "2021-10-22T01:03:53Z")

</div>

What’s up with the code randomly breaking here and there? Anyways nothing works and it returns sim error failed cast on undefined and it just points to a random line and when i remove said line it blames it on some other line. Everything worked fine and then it just broke. Here is the code: [https://makecode.com/\_7riLbrarAApF](https://makecode.com/_7riLbrarAApF)

---

<div class="post-metadata">

**Author:** ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)\
**Post date:** [October 22, 2021, 4:06pm UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534/2 "2021-10-22T16:06:05Z")

</div>

It appears that the game doesn’t like adding text sprites to an array.

---

<div class="post-metadata">

**Author:** ![RetroDude128](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/retrodude128/32/5036_2.png) [@RetroDude128](https://forum.makecode.com/u/RetroDude128)\
**Post date:** [October 22, 2021, 4:07pm UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534/3 "2021-10-22T16:07:12Z")

</div>

![ok](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9a66b0677868a41ce02814906a6eaeacbe6fcfd5.png)  
try removing these

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [October 22, 2021, 4:29pm UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534/4 "2021-10-22T16:29:58Z")

</div>

Looks like you forgot to initialize that array you’re using! You need to set “menuText” equal to an empty array before you start adding things to it in a loop. Like this:

 ![Screen Shot 2021-10-22 at 9.29.48 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c87e5aee6d40228d6916bf23342711d7f9e7da11.png)

(I added the block on top)

---

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [October 28, 2021, 5:06pm UTC](https://forum.makecode.com/t/so-my-code-broke-again/10534/5 "2021-10-28T17:06:07Z")

</div>

Thanks, but I figured that one after a while, and I couldn’t delete the post. It seems that for some reason switching to js deleted that block 🤔
