title: Trying to pull data from object based on extension's received from another file
body: <p>I am struggling to figure out a way to execute my string value as an object without using the eval function. Let me give some background so it makes more sense.
  I am pulling the data from an object called tempArray. I have set</p>
  <pre><code>tempArray.values= {
  &quot;data&quot;: {
      &quot;nonEditable&quot;: [
          {
              &quot;name&quot;: &quot;organization Name&quot;,
              &quot;value&quot;: &quot;Name of organization /&quot;
          },
          {
              &quot;name&quot;: &quot;Description&quot;,
              &quot;value&quot;: &quot;&quot;
          },
          ...
          ]}}
  </code></pre>
  <p>I am trying to make it so that I can dynamically get the extension for tempArray.values from another file called FieldLengths so that it is easy to change the locations where to pull data from in the future</p>
  <pre><code>const FieldLengths = (field) =&gt; {
  var length, dataLocations
  switch (field){
      case 'Department':
          length = 40
          dataLocations = ['data.nonEditable[0].name', 'data.editable[0].name' ]
          break
  </code></pre>
  <p>I am currently using a nested loop like this to try and achieve my goal</p>
  <pre><code>for(var k=0; k&lt;tempArray.length; k++){
        tempArray[k].selectionValues = []
        for(var i=0; i&lt;Fields.length; i++){
          dataLocations[i] = FieldProperties(Fields[i])[1]
          for(var j=0; j&lt;dataLocations[i].length; j++){
            console.log(dataLocations[i][j]) //'data.nonEditable[0].name'
            let tempVal = 'tempArray[' + k '].values' + dataLocations[i][j]
            console.log(tempVal) //'tempArray[0].values.data.nonEditable[0].name'
            //I am trying to call that string value but don't know how without using eval()
          }
        }
      }
  </code></pre>
  <p>I am assuming that there is a way to do this without eval so any help would be appreciated. Thanks ahead of time</p>