How do i append a tbbody and row to a already created table in javascript. So far i have done this

How do i append a tbbody and row to a already created table in javascript. So far i have done this
0

#1
 
 function createTable {
 	var tbl = document.getElementsByTagName('table')[0];
   
    var tblbdy = document.createElement('tbody');

    for (var i = 0; i <= 99; i++){

      var tblrw = document.createElement('tr');

      for (var j = 0; j <= 7; j++){

        var tbltd = document.createElement('td');
        var tbldata = document.createTextNode('text for' + j + "is here");
        
        tbltd.appendChild(tbldata);
        tblrw.appendChild(tbltd);

      }

      tblbdy.appendChild(tblrw);


    }

      tbl.appendChild(tblbdy);

      alert("done");
 }

 createTable();

#2

So your problem is in your very first line.

let createTable = function(){

or

function createTable(){

The only real problem? You’re missing the parenthesis.


#3

Ha yes. I have fixed that. But i am still getting this error

Uncaught TypeError: tbl.appendChild is not a function
at createTable (script.js:26)
at script.js:30