title: How to create a nested object given an array of keys
body: <p>Given is an array like this:</p>
  
  <pre><code>var level = ["a", "b", "x"];
  </code></pre>
  
  <p>The output should be:</p>
  
  <pre><code>{
      "a": {
          "b": {
              "x": {
              }
          }
      }
  }
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>var level = ["a", "b", "x"];
  var o = {};
  for (var c = 0, len = level.length; c &lt; len; c +=1 ) { 
      var part = level[c]; 
      o[part] = {}; // how to remember the last part?
  }
  </code></pre>
  
  <p>How can I remember the last part and add the next level?</p>