title: JavaScript: creating a map that maps multiple keys to a value?
body: <p>I have a list of keys and a value. For example:</p>
  
  <pre><code>keys = ["keyA", "keyB", "keyC"];
  
  value = 100;
  </code></pre>
  
  <p>I'm trying to create a function to create a map so that:</p>
  
  <pre><code>map["keyA"]["keyB"]["keyC"] = 100;
  </code></pre>
  
  <p>I assumed this was the best data structure based on the answer given <a href="https://stackoverflow.com/questions/8595559/javascript-map-with-two-values-in-the-key">here</a>:</p>
  
  <p>Anyway, the part that challenges me is that I need a function that will create a map for any number of keys. I've tried doing this in a loop but can't get it to work because I don't know how to access different levels of my map, but it also feels sloppy:</p>
  
  <pre><code>for(var i=0; i&lt;keys.length; i++){
      for(var j=0; j&lt;i; j++){
          maps[keys[0]]...[keys[j]] = {};
          if(j+1 === i){
              maps[keys[0]]...[keys[j]][keys[i]] = value;
          }
      }
  }
  </code></pre>
  
  <p>How can I create my map?</p>