title: jquery function has string parameter to access object
body: <p>I'm trying to create a shoe conversion function...here's the idea:</p>
  
  <ul>
  <li>I have two arrays, one for US shoe size and another for EU shoe size</li>
  <li>I have a conversion function that does takes in the US shoe size and the country to convert to.</li>
  <li>The function looks for the shoe size passed in to find the its index in the US array.</li>
  <li><p>Next the function takes the index found to access the item in the same index position in the EU array.</p>
  
  <pre><code>//Shoe size arrays
  var US = [3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 13, 14, 15, 16];
  var EU = [35, 35.5, 36, 37, 37.5, 38, 38.5, 39, 40, 41, 41.5, 42, 42.5, 43, 44, 44.5, 45, 46, 47, 48, 49, 50];
  
  
  var currentsize = 6.5;
  var countrycode = 'EU';
  convertShoeSize(currentsize, countrycode);
  
  function convertShoeSize(size, converto){
      var sizelocation = $.inArray(size, US);
      console.log(size + ' is at index ' + sizelocation);
      console.log('going to ' + converto);
      console.log(typeof(converto));
      console.log(typeof(EU));
      //this is where I want the parameter to access the array
      //with the same name, so the EU array created at top
      var converted = converto[sizelocation];
      console.log(converted);
  
  }
  </code></pre></li>
  </ul>
  
  <p>The parameter countrycode is coming in as a string, I want to use that string to match my array object with the same name (commented above). Get the result of <em>undefined</em>. </p>
  
  <p>If I use:</p>
  
  <p><code>var converted = converto[1]</code></p>
  
  <p>I get U, likewise if I ask for index 0 I get E. So I know I'm not accessing the EU array, I'm just looking at the string. </p>
  
  <p>How can I take a string parameter to match an object with an identical name.</p>
  
  <p>This is really basic I'm sure but I've not been able to find an answer over that last few hours anywhere online. Imagine I'm using incorrect terms in my search. Thank you!</p>