title: How to access dictionary values using a variable: Javascript
body: <p>How can I access a dictionary value using a for loop and an array?</p>
  
  <p>For example:
  I have a dictionary:</p>
  
  <pre><code>var dict = {
      machine_41: {
          temp: "14",
          humidity: "89",
          time: Wed Oct 31 2018 12: 27: 16 GMT - 0500(Central Daylight Time)
      },
      machine_42: {
          temp: "20",
          humidity: "13",
          time: Wed Oct 31 2018 12: 27: 41 GMT - 0500(Central Daylight Time)
      },
      machine_43: {
          temp: "34",
          humidity: "36",
          time: Wed Oct 31 2018 1 GMT - 0500(Central Daylight Time)
      }
  </code></pre>
  
  <p>I know I can access values by using <code>console.log(dict.machine_41.temp)</code>
  However, how can I do this with a for loop, and an array? </p>
  
  <p>I have tried:</p>
  
  <pre><code>      let activeMachines = [41,43,45];
        for(let i = 0; i &lt; activeMachines.length; i++){
            let machine = ('machine_'+ activeMachines[i]);
            console.log(htmldata.machine.temp);
         }
  </code></pre>
  
  <p>I was hoping it would substitute <code>machine</code> for <code>machine_41</code>, and so on.</p>