function createTable () {
        
    const table = document.querySelector('.table')    
    const tableRow = document.createElement('tr')
    const tableData = document.createElement('td')
    const tableHeader = document.createElement('th')
    if(names[i].length<2){
    tableHeader.textContent = names[i]
    tableRow.insertAdjacentElement('beforeend',tableHeader)
    table.insertAdjacentElement('beforeend', tableRow)
    }else {
    tableData.textContent = names[i]
    tableRow.classList.add('tableData')
    tableRow.insertAdjacentElement('beforeend',tableData)
    table.insertAdjacentElement('beforeend', tableRow)
    }
    
i++
}
// create the table with th or td
create the table with th or td
create the table with th or td
function createTable () {
    const table = document.querySelector('.table')    
    const tableRow = document.createElement('tr')
    const tableData = document.createElement('td')
    const tableHeader = document.createElement('th')
    if(names[i].length<2){
    tableHeader.textContent = names[i]
    tableRow.insertAdjacentElement('beforeend',tableHeader)
    table.insertAdjacentElement('beforeend', tableRow)
    }else {
    tableData.textContent = names[i]
    tableRow.classList.add('tableData')
    tableRow.insertAdjacentElement('beforeend',tableData)
    table.insertAdjacentElement('beforeend', tableRow)
    }
i++
}
function createTable ( ) { const table = document . querySelector ( '.table' ) const tableRow = document . createElement ( 'tr' ) const tableData = document . createElement ( 'td' ) const tableHeader = document . createElement ( 'th' ) if ( names [ i ] . length < 2 ) { tableHeader . textContent = names [ i ] tableRow . insertAdjacentElement ( 'beforeend' , tableHeader ) table . insertAdjacentElement ( 'beforeend' , tableRow ) } else { tableData . textContent = names [ i ] tableRow . classList . add ( 'tableData' ) tableRow . insertAdjacentElement ( 'beforeend' , tableData ) table . insertAdjacentElement ( 'beforeend' , tableRow ) } i ++ }
create the table with th or td
create the table with th or td