# How to loop through sprites in js

**URL:** <https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840>\
**Category:** Help\
**Created:** [April 26, 2020, 1:21pm UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840 "2020-04-26T13:21:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsea](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jsea](https://forum.makecode.com/u/jsea)\
**Post date:** [April 26, 2020, 1:21pm UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840/1 "2020-04-26T13:21:49Z")

</div>

Hi, how would I loop though this sprite and change the values to different colors?  
thx!

> **[sprite1](https://arcade.makecode.com/88070-21414-15520-66411)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [April 27, 2020, 5:28pm UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840/2 "2020-04-27T17:28:43Z")

</div>

Something like this?

```typescript
// Get an array of all sprites that have the kind "Player"
for (const sprite of sprites.allOfKind(SpriteKind.Player)) {
    // Replace all pixels with the color 0 (transparent) with 1 (white)
    sprite.image.replace(0, 1)
}

```

---

<div class="post-metadata">

**Author:** ![jsea](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jsea](https://forum.makecode.com/u/jsea)\
**Post date:** [April 27, 2020, 10:17pm UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840/3 "2020-04-27T22:17:01Z")

</div>

Thanks!!!

---

<div class="post-metadata">

**Author:** ![otorp2](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/otorp2/32/940_2.png) [@otorp2](https://forum.makecode.com/u/otorp2)\
**Post date:** [May 4, 2020, 11:36am UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840/4 "2020-05-04T11:36:26Z")

</div>

cool - is allOfKind documented somewhere? I’m a noob - Where would I go to generally read and discover this js goodness

---

<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:** [May 4, 2020, 5:08pm UTC](https://forum.makecode.com/t/how-to-loop-through-sprites-in-js/1840/5 "2020-05-04T17:08:15Z")

</div>

Our references are mostly block focused, but they’re located here:

> **[Reference](https://arcade.makecode.com/reference)**
>
> sprites,
> controller,
> game,
> music,
> scene,
> info,
> images

In general I think the most useful reference in text is the toolbox that appears on the left hand side. Most of the APIs should show up there!
