title: Traverse down a JSON depending on length of array
body: <p>Say I have a json</p>
  
  <pre><code>jsonData = {
     "id":"dfd",
     "properties":{
        "Pri":"2",
        "Brief Description":"asdf",
        "Description":"",
        "tree":{
          "var": "2",
          "rav": "3"
        }
      }   
  }
  </code></pre>
  
  <p>and a list </p>
  
  <pre><code>var variableArray = ['properties', 'tree', 'var'];
  </code></pre>
  
  <p>If I want to access the value of var and edit it. How would I do that while maintaining the value of jsonData?</p>
  
  <p>I've tried</p>
  
  <pre><code>for (var i = 0; i &lt; variableArray.length; i++) {
    jsonData = jsonData[variableArray[i]];
  }
  jsonData = 'new value';
  </code></pre>
  
  <p>But I can no longer access the whole jsonData.</p>
  
  <p>What are some way to implement this?</p>