# Array in function

**URL:** <https://forum.kirupa.com/t/array-in-function/254072>\
**Category:** Uncategorized\
**Created:** [March 7, 2008, 6:29pm UTC](https://forum.kirupa.com/t/array-in-function/254072 "2008-03-07T18:29:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![natronp](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@natronp](https://forum.kirupa.com/u/natronp)\
**Post date:** [March 7, 2008, 6:29pm UTC](https://forum.kirupa.com/t/array-in-function/254072/1 "2008-03-07T18:29:38Z")

</div>

i’m trying to assemble a reference to an array within a function and then pass the appropriate array on to another function. should be simple, but can’t seem to iron it out.

something like this:

```auto
_global.monkeyArray=new Array("monkeyOne", "monkeyTwo", "monkeyThree");

_global.fishArray=new Array("fishOne", "fishTwo", "fishThree");

myFunction=function(myString){
nArray=_root[myString+"Array"];
myotherfunction(nArray);

}

```

myotherfunction being a function looking for an array to be passed in.  
Then i can pass in “monkey”, “fish”, whatever and it’ll reference the associated array.

i know i’m not constructing the reference to the array properly but i’ve tried it several different ways now… brain is refusing to cooperate.
