title: Adding <th> to the table in js
body: <p>I'm trying to add <code>&lt;th&gt;</code> tag to the table, but I am not able to add. I want to add <code>Id</code>, <code>Name</code> and <code>Prof</code> as a table header.</p>
  
  <pre><code>var obj=[{id:"01",name:"Bob",prof:"Soft Engg"},{id:"02",name:"George",prof:"Admin"},{id:"03",name:"Paul",prof:"Front End"}];
  var table = document.createElement("table");
  table.setAttribute("id","myTable");
  document.body.appendChild(table);
  
  for(i=0;i&lt;obj.length;i++) {
    var row = document.createElement("tr")
    table.appendChild(row);
    var head = document.createElement("th");
    row.appendChild(head);
    for (key in obj[i]) {
      var cell = document.createElement("td");
      row.appendChild(cell);
      cell.innerHTML = obj[i][key];
    }
  }
  </code></pre>