I have a table where I am inserting data into the table from a query. Because I am treating every key and pair as a text when I insert the image it is returning [object HTMLImageElement]. Because I am converting it to text after the fact it is not rendering properly. Is there a better way of doing this?
            if (condition) == 1) {
               var image = document.createElement("img");
               image.src = "source1.png";
             } else if (condition) == 0 ) {
               var image = document.createElement("img");
               image.src = "source2.png";
             }
             let Table = [
               {'First Text Item': 'Text Result'),
               'Second Text Item': 'Text Result',
               'Third Text Item': 'Text Result',
               'Fourth Text Item': 'Text Result',
               'Fifth Text Item': 'Text Result',
               'Image': image},
             ];
             function generateTable(table, data) {
               for (let element of data) {
                 let row = table.insertRow();
                 for (key in element) {
                   let cell = row.insertCell();
                   let text = document.createTextNode(element[key]);
                   cell.appendChild(text);
                 }
               }
             }
             generateTable(table, Table);