title: json javascript not printing the correct output
body: <p>I am new to javascript and I'm trying to convert a valid json string into a table. here is my code:</p>
  
  <pre><code>function printTable(){
      var txt = $("#txtInput").val();
      var obj;
      try {
          obj = JSON.parse(txt);
      } catch (e) {
          alert(e);
      }
      var str = "&lt;thead&gt;&lt;th&gt;name&lt;/th&gt; &lt;th&gt;population&lt;/th&gt; &lt;th&gt;capital&lt;/th&gt; &lt;th&gt;currency&lt;/th&gt; &lt;/thead&gt;";
      var tr;
      for (var i = 0; i &lt; obj.length; i++){
          var country = obj[i];
          str+="&lt;tr&gt;&lt;td&gt;";
          str+=country.name+"&lt;/td&gt;";
          str+="&lt;td&gt;"+country.population+"&lt;/td&gt;";
          str+="&lt;td&gt;"+country.capital+"&lt;/td&gt;";
          str+="&lt;td&gt;"+country.currency+"&lt;/td&gt;";
      }
      $("#table").append(str);
  }
  </code></pre>
  
  <p>the problem is, it is not printing the correct output. it prints "name population capital currency". the <code>JSON</code> string is:</p>
  
  <blockquote>
    <p>{
      "countries": [
          {"name": "France", "population": "66000000", "capital": "Paris", "currency": "eur"},
          {"name": "Germany", "population": "82620000", "capital": "Berlin", "currency": "eur"},
          {"name": "Norway", "population": "5233000", "capital": "Oslo", "currency": "nok"},
          {"name": "Russia", "population": "144526000", "capital": "Moscow", "currency": "rub"}
        ] 
    }</p>
  </blockquote>
  
  <p>I would appreciate any help. thank you.</p>