title: Iterating through a javascript object to get key-value pairs
body: <p>Here's my code:    </p>
  
  <pre><code>obj = {"TIME":123,"DATE":456}
  
  console.log(obj.TIME);
  console.log("---------")
  
  for (var key in obj) {
    console.log(key);
    console.log(obj.key);
  }
  </code></pre>
  
  <p>It prints as the following:</p>
  
  <pre><code>123
  ---------
  TIME
  undefined
  DATE
  undefined
  </code></pre>
  
  <p>Why does console.log(obj.key) print as undefined?</p>
  
  <p>I want my code to print out the following, using obj.key to print out the value for each key:</p>
  
  <pre><code>123
  ---------
  TIME
  123
  DATE
  456
  </code></pre>
  
  <p>How do I do so?</p>