# Array bug with classes?

**URL:** <https://forum.makecode.com/t/array-bug-with-classes/39331>\
**Category:** Help\
**Tags:** game\
**Created:** [September 17, 2025, 5:34pm UTC](https://forum.makecode.com/t/array-bug-with-classes/39331 "2025-09-17T17:34:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BioShrimpCoding](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bioshrimpcoding/32/13238_2.png) [@BioShrimpCoding](https://forum.makecode.com/u/BioShrimpCoding)\
**Post date:** [September 17, 2025, 5:34pm UTC](https://forum.makecode.com/t/array-bug-with-classes/39331/1 "2025-09-17T17:34:06Z")

</div>

![Screenshot 2025-09-17 9.09.49 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/8/18bf75748a24ec65a7169c4a5f328a2eb6d4b4f1.png)

I am trying to add the Object into my array, amountOfZombie, the object “Zom” should be able to be added. I dont understand the bug and could someone fix it please

---

<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:** [September 17, 2025, 5:35pm UTC](https://forum.makecode.com/t/array-bug-with-classes/39331/2 "2025-09-17T17:35:23Z")

</div>

@BioShrimpCoding you forgot to initialize the array. in javascript variables are initialized to undefined unless you assign them.

e.g.

```typescript
let amountOfZombies: zombieKind[] = []

```

---

<div class="post-metadata">

**Author:** ![BioShrimpCoding](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bioshrimpcoding/32/13238_2.png) [@BioShrimpCoding](https://forum.makecode.com/u/BioShrimpCoding)\
**Post date:** [September 17, 2025, 10:41pm UTC](https://forum.makecode.com/t/array-bug-with-classes/39331/3 "2025-09-17T22:41:34Z")

</div>

Than you so much, i was so confused and it was genuanlly making me mad
