Can't use a list on .isTouching

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”;

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

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

nevermind! it just clicked in my head thank you