# System based off randomized features

**URL:** <https://forum.makecode.com/t/system-based-off-randomized-features/44269>\
**Category:** Help\
**Created:** [May 31, 2026, 8:05pm UTC](https://forum.makecode.com/t/system-based-off-randomized-features/44269 "2026-05-31T20:05:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phosphophyllite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/phosphophyllite/32/32491_2.png) [@phosphophyllite](https://forum.makecode.com/u/phosphophyllite)\
**Post date:** [May 31, 2026, 8:05pm UTC](https://forum.makecode.com/t/system-based-off-randomized-features/44269/1 "2026-05-31T20:05:41Z")

</div>

Hello, I’m making a game where you act as a police sketch artist. I have to code a system that detects what the true features are and change variables (such as character dialogue and accuracy of the players sketch) depending on that.

I was planning to just do a bunch of if statements to check what feature is the true one, but I was wondering if there was a more efficient way to do so. Sorry if this question is somewhat incoherent. I’m confused and would like some tips or advice.

> **[CS FINAL](https://arcade.makecode.com/S33894-58077-90958-90525)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [May 31, 2026, 8:09pm UTC](https://forum.makecode.com/t/system-based-off-randomized-features/44269/2 "2026-05-31T20:09:17Z")

</div>

Using `if` statements is not a bad thing … but, since you’re programming in JavaScript, the `switch` statement is a little more elegant:

```typescript
switch (level) {
    case 1:
        // Do something
        break

    case 2:
        // Do something else
        break

    default:
        // Code here will run if no other cases were selected
}

```

A much better way to do this, though, would be to use arrays if that makes sense for your code.

```typescript
let witnessImages: Image[] = [
    assets.image`witness1`,
    assets.image`witness2`,
    ....
]

witness.setImage(witnessImages[level])

```

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [June 1, 2026, 4:55pm UTC](https://forum.makecode.com/t/system-based-off-randomized-features/44269/3 "2026-06-01T16:55:02Z")

</div>

arrays would be best, if statements tend to get long and messy  
also this seems like a super cool game!

fellow hnk fan spotted 👀
