return functions for arrays
<p>Need a bit of help completing a Javascript program which uses succesive functions. I cant find a way of replacing the return statement with variable so I can use the varable in the second function. </p>

<p>The program uses the statement <code>findArrayparts(myArray1, myArray2)</code> to get the function <code>findArrayparts(myArray1, myArray2)</code> to generate a random integer one less then the array length of one of the arrays ( equal lengths).</p>

<p>This random integer is then used in the function <code>findArrayparts(myArray1, myArray2)</code> to work out the corresponding array elements and put them into an array which is then displayed in an alert box.</p>

<pre><code>&lt;SCRIPT SRC = glossary.js&gt;&lt;/SCRIPT&gt;
&lt;SCRIPT language = "JavaScript"&gt;
var myVar1;
var myVar2;
var myVar3;

var myArray1 = ['red', 'orange', 'green', 'blue', 'yellow'];
var myArray2 = ['tomatoe', 'orange', 'apples', 'blueberry', 'banana'];

// generates random integer and assigns result to myVar1
function getNumberRand(aNum)
   {
     //return Math.floor(Math.random() * aNum); 
     myVar1 =  Math.floor(Math.random() * aNum); 
   }

   function findArrayparts(myArray1, myArray2)    
    {   
// calls getNumberRand function         
      getNumberRand(myArray1.length); 

      // works out characters at same index in both arrays
      myVar2 = (myArray1(myVar1));
      myVar3 = (myArray2(myVar1)); 

      // new array to hold output
      outputArray = new Array(myVar2, myVar3);

        // display output
      outputArray.join();
        alert(outputArray); 
    }    

// Calls findArrayparts function        
    findArrayparts(myArray1, myArray2);


&lt;/SCRIPT&gt;


&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</code></pre>
