# Can't use a list on .isTouching

**URL:** <https://forum.code.org/t/cant-use-a-list-on-istouching/38730>\
**Category:** CS Discoveries\
**Tags:** csd-unit-3\
**Created:** [November 29, 2023, 5:05pm UTC](https://forum.code.org/t/cant-use-a-list-on-istouching/38730 "2023-11-29T17:05:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![azurirou](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/azurirou/32/8803_2.png) [@azurirou](https://forum.code.org/u/azurirou)\
**Post date:** [November 29, 2023, 5:05pm UTC](https://forum.code.org/t/cant-use-a-list-on-istouching/38730/1 "2023-11-29T17:05:22Z")

</div>

i wanna make a function that returns (or sets a value to what a sprite is touching) because I can’t find a pre-made variable in the engine that does it, like sprite.x returning the x coordinates.

but if there isn’t, here’s the basic system ive come up with but i can’t figure out the problem.

var item1 = createSprite();  
var item2 = createSprite();

var entities = ;  
appendItem(entities, item1);  
appendItem(entities, item2);

function touchingWhat() {  
for(i=0;i\<entities.length;i++) {  
if(player.isTouching(entities[i]) == true) {  
return entities[i];  
} else {  
return “nothing”;  
}  
}

---

<div class="post-metadata">

**Author:** ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)\
**Post date:** [November 29, 2023, 6:31pm UTC](https://forum.code.org/t/cant-use-a-list-on-istouching/38730/2 "2023-11-29T18:31:40Z")

</div>

you can only use that if your using a group… your using an array

```auto
var entities = createGroup();

```

that function is an extention of the Array class data structure otherwise there will be a failure and you will be forced to iterate through the items on your array to compare .isTouching() since Array.prototype.isTouching is not an inherent function

---

<div class="post-metadata">

**Author:** ![azurirou](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/azurirou/32/8803_2.png) [@azurirou](https://forum.code.org/u/azurirou)\
**Post date:** [November 29, 2023, 8:19pm UTC](https://forum.code.org/t/cant-use-a-list-on-istouching/38730/3 "2023-11-29T20:19:50Z")

</div>

nevermind! it just clicked in my head thank you
