11 Replies Latest reply on Oct 17, 2017 10:07 AM by aldaffodil2

    How to Reference a Variable with a String


      I have used a series of calculations and a concatenation to build a string.  I want to use this string to then retrieve the value of a variable that has already been set.


      Here's an example:


      function endValue();
      var returnVariable  //variable for function to return - should have a value of "The Value I want in the End" when returned
      var example1 = "already";
      var example2 = "Set";
      var alreadySet = "The Value I want in the End";
      var concatenatedString = example1 + example2;//would have a value of "alreadySet"
      // here's where I'm lost. This sets the value of returnVariable to "alreadySet" instead of "The Value I want in the End"
      returnVariable = concatenatedString;
      return returnVariable; 


      I hope I've explained this well enough.  I've tried searching for help, but I'm not even sure what I'm looking for.