Code:
<body>
  <script>
    var a = ["a", 24, { foo: "bar" }];
    var b = transform(a);

   
    function transform(array)
    {
        myArray = [];       
        myTeller = [];
        for (i = 0 ; i < array.length  ; i++)
        {
          myTeller.push(i);
          myArray.push(function ja(){return array[i];})            
        }
      
      return myArray;
      return myTeller;
    }
     
    document.write(b[1]());
    document.write(myTeller);
    
  </script>
</body>
Can anyone pleas tell why b[1]() is undefined. I am searching for it all the evening I really cant understand it. The counter is working I did the test with myTeller. If i just return array[0] use in place of return array[i] it works and I have "a" as result. (OR 1 -> '24' offcourse) The advantage of a for lus is that you can use this variable you use for the loop I in my case. Because maybe the array can much bigger and you dont want to put everything manual in it. If you just look logical It has to work I realy dont understad why it isnt working. I will be so thank full for an answer. THX