# Elemental Code Help

**URL:** <https://forum.makecode.com/t/elemental-code-help/43267>\
**Category:** Global MakeCode Arcade Game Jam\
**Tags:** game\
**Created:** [April 12, 2026, 3:16am UTC](https://forum.makecode.com/t/elemental-code-help/43267 "2026-04-12T03:16:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [April 12, 2026, 3:16am UTC](https://forum.makecode.com/t/elemental-code-help/43267/1 "2026-04-12T03:16:39Z")

</div>

my code for the game I’m working on “Elemental“ keeps throwing an error and I can seem to find it

 ![arcade-Elemental (1)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/a/2/a2982aed94be9a806e61aa4d99624bc1ad8464e4.png)

@WoofWoof Pls help I will offer cat food for it(this is also my first game in js)

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [April 12, 2026, 5:28pm UTC](https://forum.makecode.com/t/elemental-code-help/43267/2 "2026-04-12T17:28:32Z")

</div>

If you hover over it in debug mode, you can see that the error is something about a failed “\_width” property read on “null”, so something that should have a “width” is probably actually null, and yeah looking at the code I can see an " img`` " line, which fails to create an image because there’s no data inside and outputs null:

 ![Screenshot 2026-04-12 at 1.20.34 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/e/ee7f4e6b2a1232541b108dab9966c2f1b03bebea.png)  
 ![Screenshot 2026-04-12 at 1.26.11 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/a/1a1dc0d468ceff81b0f4e168f50c4bef63cc0bdc.png)

So the easy solution is just to turn it into a 1x1 image containing a single transparent pixel by writing " img`.` " instead!

 ![Screenshot 2026-04-12 at 1.32.15 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/9/e9cf3026e2a5c788635c67dff7d80e210bcf0906.png)

---

<div class="post-metadata">

**Author:** ![NeverStopTheCoder](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/neverstopthecoder/32/21194_2.png) [@NeverStopTheCoder](https://forum.makecode.com/u/NeverStopTheCoder)\
**Post date:** [April 12, 2026, 5:39pm UTC](https://forum.makecode.com/t/elemental-code-help/43267/3 "2026-04-12T17:39:32Z")

</div>

well one way you can understand js betters is you will see where a block is and when you go into js you can still drag the command like a block into your project

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [April 13, 2026, 5:23pm UTC](https://forum.makecode.com/t/elemental-code-help/43267/4 "2026-04-13T17:23:44Z")

</div>

I never used those but I fixed it thank you though

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [April 13, 2026, 5:25pm UTC](https://forum.makecode.com/t/elemental-code-help/43267/5 "2026-04-13T17:25:59Z")

</div>

in the code I havent used those so it should even get referenced but I think i fixed it

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [April 13, 2026, 9:37pm UTC](https://forum.makecode.com/t/elemental-code-help/43267/6 "2026-04-13T21:37:31Z")

</div>

You were referencing the 6th one because your loop was going “i \<= 5” which runs 6 times because #5 is included, whereas “i \< 5” would run only 5 times as intended. I would recommend only using \< and not \<= in the future to avoid confusion.
