const renderTableFromJSON = (parent, jsonObj) => { const tableConstruct = json => { let tableElement = ''; for (const row in json) { tableElement += ` `; } tableElement += '
${row} ${json[row]}
'; return tableElement; } fetch(`${jsonObj}`) .then(response => response.json()) .then(luke => { parent.insertAdjacentHTML('beforeend', tableConstruct(luke)); }); } renderTableFromJSON(document.body, 'https://swapi.dev/api/people/1/');